<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Source code</title>
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<div class="sourceContainer">
<pre><span class="sourceLineNo">001</span>/* ===========================================================<a name="line.1"></a>
<span class="sourceLineNo">002</span> * JFreeChart : a free chart library for the Java(tm) platform<a name="line.2"></a>
<span class="sourceLineNo">003</span> * ===========================================================<a name="line.3"></a>
<span class="sourceLineNo">004</span> *<a name="line.4"></a>
<span class="sourceLineNo">005</span> * (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.<a name="line.5"></a>
<span class="sourceLineNo">006</span> *<a name="line.6"></a>
<span class="sourceLineNo">007</span> * Project Info:  http://www.jfree.org/jfreechart/index.html<a name="line.7"></a>
<span class="sourceLineNo">008</span> *<a name="line.8"></a>
<span class="sourceLineNo">009</span> * This library is free software; you can redistribute it and/or modify it<a name="line.9"></a>
<span class="sourceLineNo">010</span> * under the terms of the GNU Lesser General Public License as published by<a name="line.10"></a>
<span class="sourceLineNo">011</span> * the Free Software Foundation; either version 2.1 of the License, or<a name="line.11"></a>
<span class="sourceLineNo">012</span> * (at your option) any later version.<a name="line.12"></a>
<span class="sourceLineNo">013</span> *<a name="line.13"></a>
<span class="sourceLineNo">014</span> * This library is distributed in the hope that it will be useful, but<a name="line.14"></a>
<span class="sourceLineNo">015</span> * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY<a name="line.15"></a>
<span class="sourceLineNo">016</span> * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public<a name="line.16"></a>
<span class="sourceLineNo">017</span> * License for more details.<a name="line.17"></a>
<span class="sourceLineNo">018</span> *<a name="line.18"></a>
<span class="sourceLineNo">019</span> * You should have received a copy of the GNU Lesser General Public<a name="line.19"></a>
<span class="sourceLineNo">020</span> * License along with this library; if not, write to the Free Software<a name="line.20"></a>
<span class="sourceLineNo">021</span> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,<a name="line.21"></a>
<span class="sourceLineNo">022</span> * USA.<a name="line.22"></a>
<span class="sourceLineNo">023</span> *<a name="line.23"></a>
<span class="sourceLineNo">024</span> * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. <a name="line.24"></a>
<span class="sourceLineNo">025</span> * Other names may be trademarks of their respective owners.]<a name="line.25"></a>
<span class="sourceLineNo">026</span> *<a name="line.26"></a>
<span class="sourceLineNo">027</span> * ---------------<a name="line.27"></a>
<span class="sourceLineNo">028</span> * ChartPanel.java<a name="line.28"></a>
<span class="sourceLineNo">029</span> * ---------------<a name="line.29"></a>
<span class="sourceLineNo">030</span> * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors.<a name="line.30"></a>
<span class="sourceLineNo">031</span> *<a name="line.31"></a>
<span class="sourceLineNo">032</span> * Original Author:  David Gilbert (for Object Refinery Limited);<a name="line.32"></a>
<span class="sourceLineNo">033</span> * Contributor(s):   Andrzej Porebski;<a name="line.33"></a>
<span class="sourceLineNo">034</span> *                   Soren Caspersen;<a name="line.34"></a>
<span class="sourceLineNo">035</span> *                   Jonathan Nash;<a name="line.35"></a>
<span class="sourceLineNo">036</span> *                   Hans-Jurgen Greiner;<a name="line.36"></a>
<span class="sourceLineNo">037</span> *                   Andreas Schneider;<a name="line.37"></a>
<span class="sourceLineNo">038</span> *                   Daniel van Enckevort;<a name="line.38"></a>
<span class="sourceLineNo">039</span> *                   David M O'Donnell;<a name="line.39"></a>
<span class="sourceLineNo">040</span> *                   Arnaud Lelievre;<a name="line.40"></a>
<span class="sourceLineNo">041</span> *                   Matthias Rose;<a name="line.41"></a>
<span class="sourceLineNo">042</span> *                   Onno vd Akker;<a name="line.42"></a>
<span class="sourceLineNo">043</span> *                   Sergei Ivanov;<a name="line.43"></a>
<span class="sourceLineNo">044</span> *                   Ulrich Voigt - patch 2686040;<a name="line.44"></a>
<span class="sourceLineNo">045</span> *                   Alessandro Borges - patch 1460845;<a name="line.45"></a>
<span class="sourceLineNo">046</span> *                   Martin Hoeller;<a name="line.46"></a>
<span class="sourceLineNo">047</span> *<a name="line.47"></a>
<span class="sourceLineNo">048</span> * Changes (from 28-Jun-2001)<a name="line.48"></a>
<span class="sourceLineNo">049</span> * --------------------------<a name="line.49"></a>
<span class="sourceLineNo">050</span> * 28-Jun-2001 : Integrated buffering code contributed by S???ren<a name="line.50"></a>
<span class="sourceLineNo">051</span> *               Caspersen (DG);<a name="line.51"></a>
<span class="sourceLineNo">052</span> * 18-Sep-2001 : Updated header and fixed DOS encoding problem (DG);<a name="line.52"></a>
<span class="sourceLineNo">053</span> * 22-Nov-2001 : Added scaling to improve display of charts in small sizes (DG);<a name="line.53"></a>
<span class="sourceLineNo">054</span> * 26-Nov-2001 : Added property editing, saving and printing (DG);<a name="line.54"></a>
<span class="sourceLineNo">055</span> * 11-Dec-2001 : Transferred saveChartAsPNG method to new ChartUtilities<a name="line.55"></a>
<span class="sourceLineNo">056</span> *               class (DG);<a name="line.56"></a>
<span class="sourceLineNo">057</span> * 13-Dec-2001 : Added tooltips (DG);<a name="line.57"></a>
<span class="sourceLineNo">058</span> * 16-Jan-2002 : Added an optional crosshair, based on the implementation by<a name="line.58"></a>
<span class="sourceLineNo">059</span> *               Jonathan Nash. Renamed the tooltips class (DG);<a name="line.59"></a>
<span class="sourceLineNo">060</span> * 23-Jan-2002 : Implemented zooming based on code by Hans-Jurgen Greiner (DG);<a name="line.60"></a>
<span class="sourceLineNo">061</span> * 05-Feb-2002 : Improved tooltips setup.  Renamed method attemptSaveAs()<a name="line.61"></a>
<span class="sourceLineNo">062</span> *               --&gt; doSaveAs() and made it public rather than private (DG);<a name="line.62"></a>
<span class="sourceLineNo">063</span> * 28-Mar-2002 : Added a new constructor (DG);<a name="line.63"></a>
<span class="sourceLineNo">064</span> * 09-Apr-2002 : Changed initialisation of tooltip generation, as suggested by<a name="line.64"></a>
<span class="sourceLineNo">065</span> *               Hans-Jurgen Greiner (DG);<a name="line.65"></a>
<span class="sourceLineNo">066</span> * 27-May-2002 : New interactive zooming methods based on code by Hans-Jurgen<a name="line.66"></a>
<span class="sourceLineNo">067</span> *               Greiner. Renamed JFreeChartPanel --&gt; ChartPanel, moved<a name="line.67"></a>
<span class="sourceLineNo">068</span> *               constants to ChartPanelConstants interface (DG);<a name="line.68"></a>
<span class="sourceLineNo">069</span> * 31-May-2002 : Fixed a bug with interactive zooming and added a way to<a name="line.69"></a>
<span class="sourceLineNo">070</span> *               control if the zoom rectangle is filled in or drawn as an<a name="line.70"></a>
<span class="sourceLineNo">071</span> *               outline. A mouse drag gesture towards the top left now causes<a name="line.71"></a>
<span class="sourceLineNo">072</span> *               an autoRangeBoth() and is a way to undo zooms (AS);<a name="line.72"></a>
<span class="sourceLineNo">073</span> * 11-Jun-2002 : Reinstated handleClick method call in mouseClicked() to get<a name="line.73"></a>
<span class="sourceLineNo">074</span> *               crosshairs working again (DG);<a name="line.74"></a>
<span class="sourceLineNo">075</span> * 13-Jun-2002 : Added check for null popup menu in mouseDragged method (DG);<a name="line.75"></a>
<span class="sourceLineNo">076</span> * 18-Jun-2002 : Added get/set methods for minimum and maximum chart<a name="line.76"></a>
<span class="sourceLineNo">077</span> *               dimensions (DG);<a name="line.77"></a>
<span class="sourceLineNo">078</span> * 25-Jun-2002 : Removed redundant code (DG);<a name="line.78"></a>
<span class="sourceLineNo">079</span> * 27-Aug-2002 : Added get/set methods for popup menu (DG);<a name="line.79"></a>
<span class="sourceLineNo">080</span> * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG);<a name="line.80"></a>
<span class="sourceLineNo">081</span> * 22-Oct-2002 : Added translation methods for screen &lt;--&gt; Java2D, contributed<a name="line.81"></a>
<span class="sourceLineNo">082</span> *               by Daniel van Enckevort (DG);<a name="line.82"></a>
<span class="sourceLineNo">083</span> * 05-Nov-2002 : Added a chart reference to the ChartMouseEvent class (DG);<a name="line.83"></a>
<span class="sourceLineNo">084</span> * 22-Nov-2002 : Added test in zoom method for inverted axes, supplied by<a name="line.84"></a>
<span class="sourceLineNo">085</span> *               David M O'Donnell (DG);<a name="line.85"></a>
<span class="sourceLineNo">086</span> * 14-Jan-2003 : Implemented ChartProgressListener interface (DG);<a name="line.86"></a>
<span class="sourceLineNo">087</span> * 14-Feb-2003 : Removed deprecated setGenerateTooltips method (DG);<a name="line.87"></a>
<span class="sourceLineNo">088</span> * 12-Mar-2003 : Added option to enforce filename extension (see bug id<a name="line.88"></a>
<span class="sourceLineNo">089</span> *               643173) (DG);<a name="line.89"></a>
<span class="sourceLineNo">090</span> * 08-Sep-2003 : Added internationalization via use of properties<a name="line.90"></a>
<span class="sourceLineNo">091</span> *               resourceBundle (RFE 690236) (AL);<a name="line.91"></a>
<span class="sourceLineNo">092</span> * 18-Sep-2003 : Added getScaleX() and getScaleY() methods (protected) as<a name="line.92"></a>
<span class="sourceLineNo">093</span> *               requested by Irv Thomae (DG);<a name="line.93"></a>
<span class="sourceLineNo">094</span> * 12-Nov-2003 : Added zooming support for the FastScatterPlot class (DG);<a name="line.94"></a>
<span class="sourceLineNo">095</span> * 24-Nov-2003 : Minor Javadoc updates (DG);<a name="line.95"></a>
<span class="sourceLineNo">096</span> * 04-Dec-2003 : Added anchor point for crosshair calculation (DG);<a name="line.96"></a>
<span class="sourceLineNo">097</span> * 17-Jan-2004 : Added new methods to set tooltip delays to be used in this<a name="line.97"></a>
<span class="sourceLineNo">098</span> *               chart panel. Refer to patch 877565 (MR);<a name="line.98"></a>
<span class="sourceLineNo">099</span> * 02-Feb-2004 : Fixed bug in zooming trigger and added zoomTriggerDistance<a name="line.99"></a>
<span class="sourceLineNo">100</span> *               attribute (DG);<a name="line.100"></a>
<span class="sourceLineNo">101</span> * 08-Apr-2004 : Changed getScaleX() and getScaleY() from protected to<a name="line.101"></a>
<span class="sourceLineNo">102</span> *               public (DG);<a name="line.102"></a>
<span class="sourceLineNo">103</span> * 15-Apr-2004 : Added zoomOutFactor and zoomInFactor (DG);<a name="line.103"></a>
<span class="sourceLineNo">104</span> * 21-Apr-2004 : Fixed zooming bug in mouseReleased() method (DG);<a name="line.104"></a>
<span class="sourceLineNo">105</span> * 13-Jul-2004 : Added check for null chart (DG);<a name="line.105"></a>
<span class="sourceLineNo">106</span> * 04-Oct-2004 : Renamed ShapeUtils --&gt; ShapeUtilities (DG);<a name="line.106"></a>
<span class="sourceLineNo">107</span> * 11-Nov-2004 : Moved constants back in from ChartPanelConstants (DG);<a name="line.107"></a>
<span class="sourceLineNo">108</span> * 12-Nov-2004 : Modified zooming mechanism to support zooming within<a name="line.108"></a>
<span class="sourceLineNo">109</span> *               subplots (DG);<a name="line.109"></a>
<span class="sourceLineNo">110</span> * 26-Jan-2005 : Fixed mouse zooming for horizontal category plots (DG);<a name="line.110"></a>
<span class="sourceLineNo">111</span> * 11-Apr-2005 : Added getFillZoomRectangle() method, renamed<a name="line.111"></a>
<span class="sourceLineNo">112</span> *               setHorizontalZoom() --&gt; setDomainZoomable(),<a name="line.112"></a>
<span class="sourceLineNo">113</span> *               setVerticalZoom() --&gt; setRangeZoomable(), added<a name="line.113"></a>
<span class="sourceLineNo">114</span> *               isDomainZoomable() and isRangeZoomable(), added<a name="line.114"></a>
<span class="sourceLineNo">115</span> *               getHorizontalAxisTrace() and getVerticalAxisTrace(),<a name="line.115"></a>
<span class="sourceLineNo">116</span> *               renamed autoRangeBoth() --&gt; restoreAutoBounds(),<a name="line.116"></a>
<span class="sourceLineNo">117</span> *               autoRangeHorizontal() --&gt; restoreAutoDomainBounds(),<a name="line.117"></a>
<span class="sourceLineNo">118</span> *               autoRangeVertical() --&gt; restoreAutoRangeBounds() (DG);<a name="line.118"></a>
<span class="sourceLineNo">119</span> * 12-Apr-2005 : Removed working areas, added getAnchorPoint() method,<a name="line.119"></a>
<span class="sourceLineNo">120</span> *               added protected accessors for tracelines (DG);<a name="line.120"></a>
<span class="sourceLineNo">121</span> * 18-Apr-2005 : Made constants final (DG);<a name="line.121"></a>
<span class="sourceLineNo">122</span> * 26-Apr-2005 : Removed LOGGER (DG);<a name="line.122"></a>
<span class="sourceLineNo">123</span> * 01-Jun-2005 : Fixed zooming for combined plots - see bug report<a name="line.123"></a>
<span class="sourceLineNo">124</span> *               1212039, fix thanks to Onno vd Akker (DG);<a name="line.124"></a>
<span class="sourceLineNo">125</span> * 25-Nov-2005 : Reworked event listener mechanism (DG);<a name="line.125"></a>
<span class="sourceLineNo">126</span> * ------------- JFREECHART 1.0.x ---------------------------------------------<a name="line.126"></a>
<span class="sourceLineNo">127</span> * 01-Aug-2006 : Fixed minor bug in restoreAutoRangeBounds() (DG);<a name="line.127"></a>
<span class="sourceLineNo">128</span> * 04-Sep-2006 : Renamed attemptEditChartProperties() --&gt;<a name="line.128"></a>
<span class="sourceLineNo">129</span> *               doEditChartProperties() and made public (DG);<a name="line.129"></a>
<span class="sourceLineNo">130</span> * 13-Sep-2006 : Don't generate ChartMouseEvents if the panel's chart is null<a name="line.130"></a>
<span class="sourceLineNo">131</span> *               (fixes bug 1556951) (DG);<a name="line.131"></a>
<span class="sourceLineNo">132</span> * 05-Mar-2007 : Applied patch 1672561 by Sergei Ivanov, to fix zoom rectangle<a name="line.132"></a>
<span class="sourceLineNo">133</span> *               drawing for dynamic charts (DG);<a name="line.133"></a>
<span class="sourceLineNo">134</span> * 17-Apr-2007 : Fix NullPointerExceptions in zooming for combined plots (DG);<a name="line.134"></a>
<span class="sourceLineNo">135</span> * 24-May-2007 : When the look-and-feel changes, update the popup menu if there<a name="line.135"></a>
<span class="sourceLineNo">136</span> *               is one (DG);<a name="line.136"></a>
<span class="sourceLineNo">137</span> * 06-Jun-2007 : Fixed coordinates for drawing buffer image (DG);<a name="line.137"></a>
<span class="sourceLineNo">138</span> * 24-Sep-2007 : Added zoomAroundAnchor flag, and handle clearing of chart<a name="line.138"></a>
<span class="sourceLineNo">139</span> *               buffer (DG);<a name="line.139"></a>
<span class="sourceLineNo">140</span> * 25-Oct-2007 : Added default directory attribute (DG);<a name="line.140"></a>
<span class="sourceLineNo">141</span> * 07-Nov-2007 : Fixed (rare) bug in refreshing off-screen image (DG);<a name="line.141"></a>
<span class="sourceLineNo">142</span> * 07-May-2008 : Fixed bug in zooming that triggered zoom for a rectangle<a name="line.142"></a>
<span class="sourceLineNo">143</span> *               outside of the data area (DG);<a name="line.143"></a>
<span class="sourceLineNo">144</span> * 08-May-2008 : Fixed serialization bug (DG);<a name="line.144"></a>
<span class="sourceLineNo">145</span> * 15-Aug-2008 : Increased default maxDrawWidth/Height (DG);<a name="line.145"></a>
<span class="sourceLineNo">146</span> * 18-Sep-2008 : Modified creation of chart buffer (DG);<a name="line.146"></a>
<span class="sourceLineNo">147</span> * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by<a name="line.147"></a>
<span class="sourceLineNo">148</span> *               Jess Thrysoee (DG);<a name="line.148"></a>
<span class="sourceLineNo">149</span> * 13-Jan-2009 : Fixed zooming methods to trigger only one plot<a name="line.149"></a>
<span class="sourceLineNo">150</span> *               change event (DG);<a name="line.150"></a>
<span class="sourceLineNo">151</span> * 16-Jan-2009 : Use XOR for zoom rectangle only if useBuffer is false (DG);<a name="line.151"></a>
<span class="sourceLineNo">152</span> * 18-Mar-2009 : Added mouse wheel support (DG);<a name="line.152"></a>
<span class="sourceLineNo">153</span> * 19-Mar-2009 : Added panning on mouse drag support - based on Ulrich <a name="line.153"></a>
<span class="sourceLineNo">154</span> *               Voigt's patch 2686040 (DG);<a name="line.154"></a>
<span class="sourceLineNo">155</span> * 26-Mar-2009 : Changed fillZoomRectangle default to true, and only change<a name="line.155"></a>
<span class="sourceLineNo">156</span> *               cursor for CTRL-mouse-click if panning is enabled (DG);<a name="line.156"></a>
<span class="sourceLineNo">157</span> * 01-Apr-2009 : Fixed panning, and added different mouse event mask for<a name="line.157"></a>
<span class="sourceLineNo">158</span> *               MacOSX (DG);<a name="line.158"></a>
<span class="sourceLineNo">159</span> * 08-Apr-2009 : Added copy to clipboard support, based on patch 1460845<a name="line.159"></a>
<span class="sourceLineNo">160</span> *               by Alessandro Borges (DG);<a name="line.160"></a>
<span class="sourceLineNo">161</span> * 09-Apr-2009 : Added overlay support (DG);<a name="line.161"></a>
<span class="sourceLineNo">162</span> * 10-Apr-2009 : Set chartBuffer background to match ChartPanel (DG);<a name="line.162"></a>
<span class="sourceLineNo">163</span> * 05-May-2009 : Match scaling (and insets) in doCopy() (DG);<a name="line.163"></a>
<span class="sourceLineNo">164</span> * 01-Jun-2009 : Check for null chart in mousePressed() method (DG);<a name="line.164"></a>
<span class="sourceLineNo">165</span> * 08-Jun-2009 : Fixed bug in setMouseWheelEnabled() (DG);<a name="line.165"></a>
<span class="sourceLineNo">166</span> * 06-Jul-2009 : Clear off-screen buffer to fully transparent (DG);<a name="line.166"></a>
<span class="sourceLineNo">167</span> * 10-Oct-2011 : localization fix: bug #3353913 (MH);<a name="line.167"></a>
<span class="sourceLineNo">168</span> */<a name="line.168"></a>
<span class="sourceLineNo">169</span><a name="line.169"></a>
<span class="sourceLineNo">170</span>package org.jfree.chart;<a name="line.170"></a>
<span class="sourceLineNo">171</span><a name="line.171"></a>
<span class="sourceLineNo">172</span>import java.awt.AWTEvent;<a name="line.172"></a>
<span class="sourceLineNo">173</span>import java.awt.AlphaComposite;<a name="line.173"></a>
<span class="sourceLineNo">174</span>import java.awt.Color;<a name="line.174"></a>
<span class="sourceLineNo">175</span>import java.awt.Composite;<a name="line.175"></a>
<span class="sourceLineNo">176</span>import java.awt.Cursor;<a name="line.176"></a>
<span class="sourceLineNo">177</span>import java.awt.Dimension;<a name="line.177"></a>
<span class="sourceLineNo">178</span>import java.awt.Graphics;<a name="line.178"></a>
<span class="sourceLineNo">179</span>import java.awt.Graphics2D;<a name="line.179"></a>
<span class="sourceLineNo">180</span>import java.awt.GraphicsConfiguration;<a name="line.180"></a>
<span class="sourceLineNo">181</span>import java.awt.Image;<a name="line.181"></a>
<span class="sourceLineNo">182</span>import java.awt.Insets;<a name="line.182"></a>
<span class="sourceLineNo">183</span>import java.awt.Paint;<a name="line.183"></a>
<span class="sourceLineNo">184</span>import java.awt.Point;<a name="line.184"></a>
<span class="sourceLineNo">185</span>import java.awt.Rectangle;<a name="line.185"></a>
<span class="sourceLineNo">186</span>import java.awt.Toolkit;<a name="line.186"></a>
<span class="sourceLineNo">187</span>import java.awt.Transparency;<a name="line.187"></a>
<span class="sourceLineNo">188</span>import java.awt.datatransfer.Clipboard;<a name="line.188"></a>
<span class="sourceLineNo">189</span>import java.awt.event.ActionEvent;<a name="line.189"></a>
<span class="sourceLineNo">190</span>import java.awt.event.ActionListener;<a name="line.190"></a>
<span class="sourceLineNo">191</span>import java.awt.event.InputEvent;<a name="line.191"></a>
<span class="sourceLineNo">192</span>import java.awt.event.MouseEvent;<a name="line.192"></a>
<span class="sourceLineNo">193</span>import java.awt.event.MouseListener;<a name="line.193"></a>
<span class="sourceLineNo">194</span>import java.awt.event.MouseMotionListener;<a name="line.194"></a>
<span class="sourceLineNo">195</span>import java.awt.geom.AffineTransform;<a name="line.195"></a>
<span class="sourceLineNo">196</span>import java.awt.geom.Line2D;<a name="line.196"></a>
<span class="sourceLineNo">197</span>import java.awt.geom.Point2D;<a name="line.197"></a>
<span class="sourceLineNo">198</span>import java.awt.geom.Rectangle2D;<a name="line.198"></a>
<span class="sourceLineNo">199</span>import java.awt.print.PageFormat;<a name="line.199"></a>
<span class="sourceLineNo">200</span>import java.awt.print.Printable;<a name="line.200"></a>
<span class="sourceLineNo">201</span>import java.awt.print.PrinterException;<a name="line.201"></a>
<span class="sourceLineNo">202</span>import java.awt.print.PrinterJob;<a name="line.202"></a>
<span class="sourceLineNo">203</span>import java.io.File;<a name="line.203"></a>
<span class="sourceLineNo">204</span>import java.io.IOException;<a name="line.204"></a>
<span class="sourceLineNo">205</span>import java.io.ObjectInputStream;<a name="line.205"></a>
<span class="sourceLineNo">206</span>import java.io.ObjectOutputStream;<a name="line.206"></a>
<span class="sourceLineNo">207</span>import java.io.Serializable;<a name="line.207"></a>
<span class="sourceLineNo">208</span>import java.lang.reflect.Constructor;<a name="line.208"></a>
<span class="sourceLineNo">209</span>import java.lang.reflect.InvocationTargetException;<a name="line.209"></a>
<span class="sourceLineNo">210</span>import java.lang.reflect.Method;<a name="line.210"></a>
<span class="sourceLineNo">211</span>import java.util.EventListener;<a name="line.211"></a>
<span class="sourceLineNo">212</span>import java.util.Iterator;<a name="line.212"></a>
<span class="sourceLineNo">213</span>import java.util.List;<a name="line.213"></a>
<span class="sourceLineNo">214</span>import java.util.ResourceBundle;<a name="line.214"></a>
<span class="sourceLineNo">215</span><a name="line.215"></a>
<span class="sourceLineNo">216</span>import javax.swing.JFileChooser;<a name="line.216"></a>
<span class="sourceLineNo">217</span>import javax.swing.JMenu;<a name="line.217"></a>
<span class="sourceLineNo">218</span>import javax.swing.JMenuItem;<a name="line.218"></a>
<span class="sourceLineNo">219</span>import javax.swing.JOptionPane;<a name="line.219"></a>
<span class="sourceLineNo">220</span>import javax.swing.JPanel;<a name="line.220"></a>
<span class="sourceLineNo">221</span>import javax.swing.JPopupMenu;<a name="line.221"></a>
<span class="sourceLineNo">222</span>import javax.swing.SwingUtilities;<a name="line.222"></a>
<span class="sourceLineNo">223</span>import javax.swing.ToolTipManager;<a name="line.223"></a>
<span class="sourceLineNo">224</span>import javax.swing.event.EventListenerList;<a name="line.224"></a>
<span class="sourceLineNo">225</span><a name="line.225"></a>
<span class="sourceLineNo">226</span>import org.jfree.chart.editor.ChartEditor;<a name="line.226"></a>
<span class="sourceLineNo">227</span>import org.jfree.chart.editor.ChartEditorManager;<a name="line.227"></a>
<span class="sourceLineNo">228</span>import org.jfree.chart.entity.ChartEntity;<a name="line.228"></a>
<span class="sourceLineNo">229</span>import org.jfree.chart.entity.EntityCollection;<a name="line.229"></a>
<span class="sourceLineNo">230</span>import org.jfree.chart.event.ChartChangeEvent;<a name="line.230"></a>
<span class="sourceLineNo">231</span>import org.jfree.chart.event.ChartChangeListener;<a name="line.231"></a>
<span class="sourceLineNo">232</span>import org.jfree.chart.event.ChartProgressEvent;<a name="line.232"></a>
<span class="sourceLineNo">233</span>import org.jfree.chart.event.ChartProgressListener;<a name="line.233"></a>
<span class="sourceLineNo">234</span>import org.jfree.chart.panel.Overlay;<a name="line.234"></a>
<span class="sourceLineNo">235</span>import org.jfree.chart.event.OverlayChangeEvent;<a name="line.235"></a>
<span class="sourceLineNo">236</span>import org.jfree.chart.event.OverlayChangeListener;<a name="line.236"></a>
<span class="sourceLineNo">237</span>import org.jfree.chart.plot.Pannable;<a name="line.237"></a>
<span class="sourceLineNo">238</span>import org.jfree.chart.plot.Plot;<a name="line.238"></a>
<span class="sourceLineNo">239</span>import org.jfree.chart.plot.PlotOrientation;<a name="line.239"></a>
<span class="sourceLineNo">240</span>import org.jfree.chart.plot.PlotRenderingInfo;<a name="line.240"></a>
<span class="sourceLineNo">241</span>import org.jfree.chart.plot.Zoomable;<a name="line.241"></a>
<span class="sourceLineNo">242</span>import org.jfree.chart.util.ResourceBundleWrapper;<a name="line.242"></a>
<span class="sourceLineNo">243</span>import org.jfree.io.SerialUtilities;<a name="line.243"></a>
<span class="sourceLineNo">244</span>import org.jfree.ui.ExtensionFileFilter;<a name="line.244"></a>
<span class="sourceLineNo">245</span><a name="line.245"></a>
<span class="sourceLineNo">246</span>/**<a name="line.246"></a>
<span class="sourceLineNo">247</span> * A Swing GUI component for displaying a {@link JFreeChart} object.<a name="line.247"></a>
<span class="sourceLineNo">248</span> * &lt;P&gt;<a name="line.248"></a>
<span class="sourceLineNo">249</span> * The panel registers with the chart to receive notification of changes to any<a name="line.249"></a>
<span class="sourceLineNo">250</span> * component of the chart.  The chart is redrawn automatically whenever this<a name="line.250"></a>
<span class="sourceLineNo">251</span> * notification is received.<a name="line.251"></a>
<span class="sourceLineNo">252</span> */<a name="line.252"></a>
<span class="sourceLineNo">253</span>public class ChartPanel extends JPanel implements ChartChangeListener,<a name="line.253"></a>
<span class="sourceLineNo">254</span>        ChartProgressListener, ActionListener, MouseListener,<a name="line.254"></a>
<span class="sourceLineNo">255</span>        MouseMotionListener, OverlayChangeListener, Printable, Serializable {<a name="line.255"></a>
<span class="sourceLineNo">256</span><a name="line.256"></a>
<span class="sourceLineNo">257</span>    /** For serialization. */<a name="line.257"></a>
<span class="sourceLineNo">258</span>    private static final long serialVersionUID = 6046366297214274674L;<a name="line.258"></a>
<span class="sourceLineNo">259</span><a name="line.259"></a>
<span class="sourceLineNo">260</span>    /**<a name="line.260"></a>
<span class="sourceLineNo">261</span>     * Default setting for buffer usage.  The default has been changed to<a name="line.261"></a>
<span class="sourceLineNo">262</span>     * &lt;code&gt;true&lt;/code&gt; from version 1.0.13 onwards, because of a severe<a name="line.262"></a>
<span class="sourceLineNo">263</span>     * performance problem with drawing the zoom rectangle using XOR (which<a name="line.263"></a>
<span class="sourceLineNo">264</span>     * now happens only when the buffer is NOT used).<a name="line.264"></a>
<span class="sourceLineNo">265</span>     */<a name="line.265"></a>
<span class="sourceLineNo">266</span>    public static final boolean DEFAULT_BUFFER_USED = true;<a name="line.266"></a>
<span class="sourceLineNo">267</span><a name="line.267"></a>
<span class="sourceLineNo">268</span>    /** The default panel width. */<a name="line.268"></a>
<span class="sourceLineNo">269</span>    public static final int DEFAULT_WIDTH = 680;<a name="line.269"></a>
<span class="sourceLineNo">270</span><a name="line.270"></a>
<span class="sourceLineNo">271</span>    /** The default panel height. */<a name="line.271"></a>
<span class="sourceLineNo">272</span>    public static final int DEFAULT_HEIGHT = 420;<a name="line.272"></a>
<span class="sourceLineNo">273</span><a name="line.273"></a>
<span class="sourceLineNo">274</span>    /** The default limit below which chart scaling kicks in. */<a name="line.274"></a>
<span class="sourceLineNo">275</span>    public static final int DEFAULT_MINIMUM_DRAW_WIDTH = 300;<a name="line.275"></a>
<span class="sourceLineNo">276</span><a name="line.276"></a>
<span class="sourceLineNo">277</span>    /** The default limit below which chart scaling kicks in. */<a name="line.277"></a>
<span class="sourceLineNo">278</span>    public static final int DEFAULT_MINIMUM_DRAW_HEIGHT = 200;<a name="line.278"></a>
<span class="sourceLineNo">279</span><a name="line.279"></a>
<span class="sourceLineNo">280</span>    /** The default limit above which chart scaling kicks in. */<a name="line.280"></a>
<span class="sourceLineNo">281</span>    public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 1024;<a name="line.281"></a>
<span class="sourceLineNo">282</span><a name="line.282"></a>
<span class="sourceLineNo">283</span>    /** The default limit above which chart scaling kicks in. */<a name="line.283"></a>
<span class="sourceLineNo">284</span>    public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 768;<a name="line.284"></a>
<span class="sourceLineNo">285</span><a name="line.285"></a>
<span class="sourceLineNo">286</span>    /** The minimum size required to perform a zoom on a rectangle */<a name="line.286"></a>
<span class="sourceLineNo">287</span>    public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE = 10;<a name="line.287"></a>
<span class="sourceLineNo">288</span><a name="line.288"></a>
<span class="sourceLineNo">289</span>    /** Properties action command. */<a name="line.289"></a>
<span class="sourceLineNo">290</span>    public static final String PROPERTIES_COMMAND = "PROPERTIES";<a name="line.290"></a>
<span class="sourceLineNo">291</span><a name="line.291"></a>
<span class="sourceLineNo">292</span>    /**<a name="line.292"></a>
<span class="sourceLineNo">293</span>     * Copy action command.<a name="line.293"></a>
<span class="sourceLineNo">294</span>     *<a name="line.294"></a>
<span class="sourceLineNo">295</span>     * @since 1.0.13<a name="line.295"></a>
<span class="sourceLineNo">296</span>     */<a name="line.296"></a>
<span class="sourceLineNo">297</span>    public static final String COPY_COMMAND = "COPY";<a name="line.297"></a>
<span class="sourceLineNo">298</span><a name="line.298"></a>
<span class="sourceLineNo">299</span>    /** Save action command. */<a name="line.299"></a>
<span class="sourceLineNo">300</span>    public static final String SAVE_COMMAND = "SAVE";<a name="line.300"></a>
<span class="sourceLineNo">301</span><a name="line.301"></a>
<span class="sourceLineNo">302</span>    /** Print action command. */<a name="line.302"></a>
<span class="sourceLineNo">303</span>    public static final String PRINT_COMMAND = "PRINT";<a name="line.303"></a>
<span class="sourceLineNo">304</span><a name="line.304"></a>
<span class="sourceLineNo">305</span>    /** Zoom in (both axes) action command. */<a name="line.305"></a>
<span class="sourceLineNo">306</span>    public static final String ZOOM_IN_BOTH_COMMAND = "ZOOM_IN_BOTH";<a name="line.306"></a>
<span class="sourceLineNo">307</span><a name="line.307"></a>
<span class="sourceLineNo">308</span>    /** Zoom in (domain axis only) action command. */<a name="line.308"></a>
<span class="sourceLineNo">309</span>    public static final String ZOOM_IN_DOMAIN_COMMAND = "ZOOM_IN_DOMAIN";<a name="line.309"></a>
<span class="sourceLineNo">310</span><a name="line.310"></a>
<span class="sourceLineNo">311</span>    /** Zoom in (range axis only) action command. */<a name="line.311"></a>
<span class="sourceLineNo">312</span>    public static final String ZOOM_IN_RANGE_COMMAND = "ZOOM_IN_RANGE";<a name="line.312"></a>
<span class="sourceLineNo">313</span><a name="line.313"></a>
<span class="sourceLineNo">314</span>    /** Zoom out (both axes) action command. */<a name="line.314"></a>
<span class="sourceLineNo">315</span>    public static final String ZOOM_OUT_BOTH_COMMAND = "ZOOM_OUT_BOTH";<a name="line.315"></a>
<span class="sourceLineNo">316</span><a name="line.316"></a>
<span class="sourceLineNo">317</span>    /** Zoom out (domain axis only) action command. */<a name="line.317"></a>
<span class="sourceLineNo">318</span>    public static final String ZOOM_OUT_DOMAIN_COMMAND = "ZOOM_DOMAIN_BOTH";<a name="line.318"></a>
<span class="sourceLineNo">319</span><a name="line.319"></a>
<span class="sourceLineNo">320</span>    /** Zoom out (range axis only) action command. */<a name="line.320"></a>
<span class="sourceLineNo">321</span>    public static final String ZOOM_OUT_RANGE_COMMAND = "ZOOM_RANGE_BOTH";<a name="line.321"></a>
<span class="sourceLineNo">322</span><a name="line.322"></a>
<span class="sourceLineNo">323</span>    /** Zoom reset (both axes) action command. */<a name="line.323"></a>
<span class="sourceLineNo">324</span>    public static final String ZOOM_RESET_BOTH_COMMAND = "ZOOM_RESET_BOTH";<a name="line.324"></a>
<span class="sourceLineNo">325</span><a name="line.325"></a>
<span class="sourceLineNo">326</span>    /** Zoom reset (domain axis only) action command. */<a name="line.326"></a>
<span class="sourceLineNo">327</span>    public static final String ZOOM_RESET_DOMAIN_COMMAND = "ZOOM_RESET_DOMAIN";<a name="line.327"></a>
<span class="sourceLineNo">328</span><a name="line.328"></a>
<span class="sourceLineNo">329</span>    /** Zoom reset (range axis only) action command. */<a name="line.329"></a>
<span class="sourceLineNo">330</span>    public static final String ZOOM_RESET_RANGE_COMMAND = "ZOOM_RESET_RANGE";<a name="line.330"></a>
<span class="sourceLineNo">331</span><a name="line.331"></a>
<span class="sourceLineNo">332</span>    /** The chart that is displayed in the panel. */<a name="line.332"></a>
<span class="sourceLineNo">333</span>    private JFreeChart chart;<a name="line.333"></a>
<span class="sourceLineNo">334</span><a name="line.334"></a>
<span class="sourceLineNo">335</span>    /** Storage for registered (chart) mouse listeners. */<a name="line.335"></a>
<span class="sourceLineNo">336</span>    private transient EventListenerList chartMouseListeners;<a name="line.336"></a>
<span class="sourceLineNo">337</span><a name="line.337"></a>
<span class="sourceLineNo">338</span>    /** A flag that controls whether or not the off-screen buffer is used. */<a name="line.338"></a>
<span class="sourceLineNo">339</span>    private boolean useBuffer;<a name="line.339"></a>
<span class="sourceLineNo">340</span><a name="line.340"></a>
<span class="sourceLineNo">341</span>    /** A flag that indicates that the buffer should be refreshed. */<a name="line.341"></a>
<span class="sourceLineNo">342</span>    private boolean refreshBuffer;<a name="line.342"></a>
<span class="sourceLineNo">343</span><a name="line.343"></a>
<span class="sourceLineNo">344</span>    /** A buffer for the rendered chart. */<a name="line.344"></a>
<span class="sourceLineNo">345</span>    private transient Image chartBuffer;<a name="line.345"></a>
<span class="sourceLineNo">346</span><a name="line.346"></a>
<span class="sourceLineNo">347</span>    /** The height of the chart buffer. */<a name="line.347"></a>
<span class="sourceLineNo">348</span>    private int chartBufferHeight;<a name="line.348"></a>
<span class="sourceLineNo">349</span><a name="line.349"></a>
<span class="sourceLineNo">350</span>    /** The width of the chart buffer. */<a name="line.350"></a>
<span class="sourceLineNo">351</span>    private int chartBufferWidth;<a name="line.351"></a>
<span class="sourceLineNo">352</span><a name="line.352"></a>
<span class="sourceLineNo">353</span>    /**<a name="line.353"></a>
<span class="sourceLineNo">354</span>     * The minimum width for drawing a chart (uses scaling for smaller widths).<a name="line.354"></a>
<span class="sourceLineNo">355</span>     */<a name="line.355"></a>
<span class="sourceLineNo">356</span>    private int minimumDrawWidth;<a name="line.356"></a>
<span class="sourceLineNo">357</span><a name="line.357"></a>
<span class="sourceLineNo">358</span>    /**<a name="line.358"></a>
<span class="sourceLineNo">359</span>     * The minimum height for drawing a chart (uses scaling for smaller<a name="line.359"></a>
<span class="sourceLineNo">360</span>     * heights).<a name="line.360"></a>
<span class="sourceLineNo">361</span>     */<a name="line.361"></a>
<span class="sourceLineNo">362</span>    private int minimumDrawHeight;<a name="line.362"></a>
<span class="sourceLineNo">363</span><a name="line.363"></a>
<span class="sourceLineNo">364</span>    /**<a name="line.364"></a>
<span class="sourceLineNo">365</span>     * The maximum width for drawing a chart (uses scaling for bigger<a name="line.365"></a>
<span class="sourceLineNo">366</span>     * widths).<a name="line.366"></a>
<span class="sourceLineNo">367</span>     */<a name="line.367"></a>
<span class="sourceLineNo">368</span>    private int maximumDrawWidth;<a name="line.368"></a>
<span class="sourceLineNo">369</span><a name="line.369"></a>
<span class="sourceLineNo">370</span>    /**<a name="line.370"></a>
<span class="sourceLineNo">371</span>     * The maximum height for drawing a chart (uses scaling for bigger<a name="line.371"></a>
<span class="sourceLineNo">372</span>     * heights).<a name="line.372"></a>
<span class="sourceLineNo">373</span>     */<a name="line.373"></a>
<span class="sourceLineNo">374</span>    private int maximumDrawHeight;<a name="line.374"></a>
<span class="sourceLineNo">375</span><a name="line.375"></a>
<span class="sourceLineNo">376</span>    /** The popup menu for the frame. */<a name="line.376"></a>
<span class="sourceLineNo">377</span>    private JPopupMenu popup;<a name="line.377"></a>
<span class="sourceLineNo">378</span><a name="line.378"></a>
<span class="sourceLineNo">379</span>    /** The drawing info collected the last time the chart was drawn. */<a name="line.379"></a>
<span class="sourceLineNo">380</span>    private ChartRenderingInfo info;<a name="line.380"></a>
<span class="sourceLineNo">381</span><a name="line.381"></a>
<span class="sourceLineNo">382</span>    /** The chart anchor point. */<a name="line.382"></a>
<span class="sourceLineNo">383</span>    private Point2D anchor;<a name="line.383"></a>
<span class="sourceLineNo">384</span><a name="line.384"></a>
<span class="sourceLineNo">385</span>    /** The scale factor used to draw the chart. */<a name="line.385"></a>
<span class="sourceLineNo">386</span>    private double scaleX;<a name="line.386"></a>
<span class="sourceLineNo">387</span><a name="line.387"></a>
<span class="sourceLineNo">388</span>    /** The scale factor used to draw the chart. */<a name="line.388"></a>
<span class="sourceLineNo">389</span>    private double scaleY;<a name="line.389"></a>
<span class="sourceLineNo">390</span><a name="line.390"></a>
<span class="sourceLineNo">391</span>    /** The plot orientation. */<a name="line.391"></a>
<span class="sourceLineNo">392</span>    private PlotOrientation orientation = PlotOrientation.VERTICAL;<a name="line.392"></a>
<span class="sourceLineNo">393</span><a name="line.393"></a>
<span class="sourceLineNo">394</span>    /** A flag that controls whether or not domain zooming is enabled. */<a name="line.394"></a>
<span class="sourceLineNo">395</span>    private boolean domainZoomable = false;<a name="line.395"></a>
<span class="sourceLineNo">396</span><a name="line.396"></a>
<span class="sourceLineNo">397</span>    /** A flag that controls whether or not range zooming is enabled. */<a name="line.397"></a>
<span class="sourceLineNo">398</span>    private boolean rangeZoomable = false;<a name="line.398"></a>
<span class="sourceLineNo">399</span><a name="line.399"></a>
<span class="sourceLineNo">400</span>    /**<a name="line.400"></a>
<span class="sourceLineNo">401</span>     * The zoom rectangle starting point (selected by the user with a mouse<a name="line.401"></a>
<span class="sourceLineNo">402</span>     * click).  This is a point on the screen, not the chart (which may have<a name="line.402"></a>
<span class="sourceLineNo">403</span>     * been scaled up or down to fit the panel).<a name="line.403"></a>
<span class="sourceLineNo">404</span>     */<a name="line.404"></a>
<span class="sourceLineNo">405</span>    private Point2D zoomPoint = null;<a name="line.405"></a>
<span class="sourceLineNo">406</span><a name="line.406"></a>
<span class="sourceLineNo">407</span>    /** The zoom rectangle (selected by the user with the mouse). */<a name="line.407"></a>
<span class="sourceLineNo">408</span>    private transient Rectangle2D zoomRectangle = null;<a name="line.408"></a>
<span class="sourceLineNo">409</span><a name="line.409"></a>
<span class="sourceLineNo">410</span>    /** Controls if the zoom rectangle is drawn as an outline or filled. */<a name="line.410"></a>
<span class="sourceLineNo">411</span>    private boolean fillZoomRectangle = true;<a name="line.411"></a>
<span class="sourceLineNo">412</span><a name="line.412"></a>
<span class="sourceLineNo">413</span>    /** The minimum distance required to drag the mouse to trigger a zoom. */<a name="line.413"></a>
<span class="sourceLineNo">414</span>    private int zoomTriggerDistance;<a name="line.414"></a>
<span class="sourceLineNo">415</span><a name="line.415"></a>
<span class="sourceLineNo">416</span>    /** A flag that controls whether or not horizontal tracing is enabled. */<a name="line.416"></a>
<span class="sourceLineNo">417</span>    private boolean horizontalAxisTrace = false;<a name="line.417"></a>
<span class="sourceLineNo">418</span><a name="line.418"></a>
<span class="sourceLineNo">419</span>    /** A flag that controls whether or not vertical tracing is enabled. */<a name="line.419"></a>
<span class="sourceLineNo">420</span>    private boolean verticalAxisTrace = false;<a name="line.420"></a>
<span class="sourceLineNo">421</span><a name="line.421"></a>
<span class="sourceLineNo">422</span>    /** A vertical trace line. */<a name="line.422"></a>
<span class="sourceLineNo">423</span>    private transient Line2D verticalTraceLine;<a name="line.423"></a>
<span class="sourceLineNo">424</span><a name="line.424"></a>
<span class="sourceLineNo">425</span>    /** A horizontal trace line. */<a name="line.425"></a>
<span class="sourceLineNo">426</span>    private transient Line2D horizontalTraceLine;<a name="line.426"></a>
<span class="sourceLineNo">427</span><a name="line.427"></a>
<span class="sourceLineNo">428</span>    /** Menu item for zooming in on a chart (both axes). */<a name="line.428"></a>
<span class="sourceLineNo">429</span>    private JMenuItem zoomInBothMenuItem;<a name="line.429"></a>
<span class="sourceLineNo">430</span><a name="line.430"></a>
<span class="sourceLineNo">431</span>    /** Menu item for zooming in on a chart (domain axis). */<a name="line.431"></a>
<span class="sourceLineNo">432</span>    private JMenuItem zoomInDomainMenuItem;<a name="line.432"></a>
<span class="sourceLineNo">433</span><a name="line.433"></a>
<span class="sourceLineNo">434</span>    /** Menu item for zooming in on a chart (range axis). */<a name="line.434"></a>
<span class="sourceLineNo">435</span>    private JMenuItem zoomInRangeMenuItem;<a name="line.435"></a>
<span class="sourceLineNo">436</span><a name="line.436"></a>
<span class="sourceLineNo">437</span>    /** Menu item for zooming out on a chart. */<a name="line.437"></a>
<span class="sourceLineNo">438</span>    private JMenuItem zoomOutBothMenuItem;<a name="line.438"></a>
<span class="sourceLineNo">439</span><a name="line.439"></a>
<span class="sourceLineNo">440</span>    /** Menu item for zooming out on a chart (domain axis). */<a name="line.440"></a>
<span class="sourceLineNo">441</span>    private JMenuItem zoomOutDomainMenuItem;<a name="line.441"></a>
<span class="sourceLineNo">442</span><a name="line.442"></a>
<span class="sourceLineNo">443</span>    /** Menu item for zooming out on a chart (range axis). */<a name="line.443"></a>
<span class="sourceLineNo">444</span>    private JMenuItem zoomOutRangeMenuItem;<a name="line.444"></a>
<span class="sourceLineNo">445</span><a name="line.445"></a>
<span class="sourceLineNo">446</span>    /** Menu item for resetting the zoom (both axes). */<a name="line.446"></a>
<span class="sourceLineNo">447</span>    private JMenuItem zoomResetBothMenuItem;<a name="line.447"></a>
<span class="sourceLineNo">448</span><a name="line.448"></a>
<span class="sourceLineNo">449</span>    /** Menu item for resetting the zoom (domain axis only). */<a name="line.449"></a>
<span class="sourceLineNo">450</span>    private JMenuItem zoomResetDomainMenuItem;<a name="line.450"></a>
<span class="sourceLineNo">451</span><a name="line.451"></a>
<span class="sourceLineNo">452</span>    /** Menu item for resetting the zoom (range axis only). */<a name="line.452"></a>
<span class="sourceLineNo">453</span>    private JMenuItem zoomResetRangeMenuItem;<a name="line.453"></a>
<span class="sourceLineNo">454</span><a name="line.454"></a>
<span class="sourceLineNo">455</span>    /**<a name="line.455"></a>
<span class="sourceLineNo">456</span>     * The default directory for saving charts to file.<a name="line.456"></a>
<span class="sourceLineNo">457</span>     *<a name="line.457"></a>
<span class="sourceLineNo">458</span>     * @since 1.0.7<a name="line.458"></a>
<span class="sourceLineNo">459</span>     */<a name="line.459"></a>
<span class="sourceLineNo">460</span>    private File defaultDirectoryForSaveAs;<a name="line.460"></a>
<span class="sourceLineNo">461</span><a name="line.461"></a>
<span class="sourceLineNo">462</span>    /** A flag that controls whether or not file extensions are enforced. */<a name="line.462"></a>
<span class="sourceLineNo">463</span>    private boolean enforceFileExtensions;<a name="line.463"></a>
<span class="sourceLineNo">464</span><a name="line.464"></a>
<span class="sourceLineNo">465</span>    /** A flag that indicates if original tooltip delays are changed. */<a name="line.465"></a>
<span class="sourceLineNo">466</span>    private boolean ownToolTipDelaysActive;<a name="line.466"></a>
<span class="sourceLineNo">467</span><a name="line.467"></a>
<span class="sourceLineNo">468</span>    /** Original initial tooltip delay of ToolTipManager.sharedInstance(). */<a name="line.468"></a>
<span class="sourceLineNo">469</span>    private int originalToolTipInitialDelay;<a name="line.469"></a>
<span class="sourceLineNo">470</span><a name="line.470"></a>
<span class="sourceLineNo">471</span>    /** Original reshow tooltip delay of ToolTipManager.sharedInstance(). */<a name="line.471"></a>
<span class="sourceLineNo">472</span>    private int originalToolTipReshowDelay;<a name="line.472"></a>
<span class="sourceLineNo">473</span><a name="line.473"></a>
<span class="sourceLineNo">474</span>    /** Original dismiss tooltip delay of ToolTipManager.sharedInstance(). */<a name="line.474"></a>
<span class="sourceLineNo">475</span>    private int originalToolTipDismissDelay;<a name="line.475"></a>
<span class="sourceLineNo">476</span><a name="line.476"></a>
<span class="sourceLineNo">477</span>    /** Own initial tooltip delay to be used in this chart panel. */<a name="line.477"></a>
<span class="sourceLineNo">478</span>    private int ownToolTipInitialDelay;<a name="line.478"></a>
<span class="sourceLineNo">479</span><a name="line.479"></a>
<span class="sourceLineNo">480</span>    /** Own reshow tooltip delay to be used in this chart panel. */<a name="line.480"></a>
<span class="sourceLineNo">481</span>    private int ownToolTipReshowDelay;<a name="line.481"></a>
<span class="sourceLineNo">482</span><a name="line.482"></a>
<span class="sourceLineNo">483</span>    /** Own dismiss tooltip delay to be used in this chart panel. */<a name="line.483"></a>
<span class="sourceLineNo">484</span>    private int ownToolTipDismissDelay;<a name="line.484"></a>
<span class="sourceLineNo">485</span><a name="line.485"></a>
<span class="sourceLineNo">486</span>    /** The factor used to zoom in on an axis range. */<a name="line.486"></a>
<span class="sourceLineNo">487</span>    private double zoomInFactor = 0.5;<a name="line.487"></a>
<span class="sourceLineNo">488</span><a name="line.488"></a>
<span class="sourceLineNo">489</span>    /** The factor used to zoom out on an axis range. */<a name="line.489"></a>
<span class="sourceLineNo">490</span>    private double zoomOutFactor = 2.0;<a name="line.490"></a>
<span class="sourceLineNo">491</span><a name="line.491"></a>
<span class="sourceLineNo">492</span>    /**<a name="line.492"></a>
<span class="sourceLineNo">493</span>     * A flag that controls whether zoom operations are centred on the<a name="line.493"></a>
<span class="sourceLineNo">494</span>     * current anchor point, or the centre point of the relevant axis.<a name="line.494"></a>
<span class="sourceLineNo">495</span>     *<a name="line.495"></a>
<span class="sourceLineNo">496</span>     * @since 1.0.7<a name="line.496"></a>
<span class="sourceLineNo">497</span>     */<a name="line.497"></a>
<span class="sourceLineNo">498</span>    private boolean zoomAroundAnchor;<a name="line.498"></a>
<span class="sourceLineNo">499</span><a name="line.499"></a>
<span class="sourceLineNo">500</span>    /**<a name="line.500"></a>
<span class="sourceLineNo">501</span>     * The paint used to draw the zoom rectangle outline.<a name="line.501"></a>
<span class="sourceLineNo">502</span>     *<a name="line.502"></a>
<span class="sourceLineNo">503</span>     * @since 1.0.13<a name="line.503"></a>
<span class="sourceLineNo">504</span>     */<a name="line.504"></a>
<span class="sourceLineNo">505</span>    private transient Paint zoomOutlinePaint;<a name="line.505"></a>
<span class="sourceLineNo">506</span><a name="line.506"></a>
<span class="sourceLineNo">507</span>    /**<a name="line.507"></a>
<span class="sourceLineNo">508</span>     * The zoom fill paint (should use transparency).<a name="line.508"></a>
<span class="sourceLineNo">509</span>     *<a name="line.509"></a>
<span class="sourceLineNo">510</span>     * @since 1.0.13<a name="line.510"></a>
<span class="sourceLineNo">511</span>     */<a name="line.511"></a>
<span class="sourceLineNo">512</span>    private transient Paint zoomFillPaint;<a name="line.512"></a>
<span class="sourceLineNo">513</span><a name="line.513"></a>
<span class="sourceLineNo">514</span>    /** The resourceBundle for the localization. */<a name="line.514"></a>
<span class="sourceLineNo">515</span>    protected static ResourceBundle localizationResources<a name="line.515"></a>
<span class="sourceLineNo">516</span>            = ResourceBundleWrapper.getBundle(<a name="line.516"></a>
<span class="sourceLineNo">517</span>                    "org.jfree.chart.LocalizationBundle");<a name="line.517"></a>
<span class="sourceLineNo">518</span><a name="line.518"></a>
<span class="sourceLineNo">519</span>    /** <a name="line.519"></a>
<span class="sourceLineNo">520</span>     * Temporary storage for the width and height of the chart <a name="line.520"></a>
<span class="sourceLineNo">521</span>     * drawing area during panning.<a name="line.521"></a>
<span class="sourceLineNo">522</span>     */<a name="line.522"></a>
<span class="sourceLineNo">523</span>    private double panW, panH;<a name="line.523"></a>
<span class="sourceLineNo">524</span><a name="line.524"></a>
<span class="sourceLineNo">525</span>    /** The last mouse position during panning. */<a name="line.525"></a>
<span class="sourceLineNo">526</span>    private Point panLast;<a name="line.526"></a>
<span class="sourceLineNo">527</span><a name="line.527"></a>
<span class="sourceLineNo">528</span>    /**<a name="line.528"></a>
<span class="sourceLineNo">529</span>     * The mask for mouse events to trigger panning.<a name="line.529"></a>
<span class="sourceLineNo">530</span>     *<a name="line.530"></a>
<span class="sourceLineNo">531</span>     * @since 1.0.13<a name="line.531"></a>
<span class="sourceLineNo">532</span>     */<a name="line.532"></a>
<span class="sourceLineNo">533</span>    private int panMask = InputEvent.CTRL_MASK;<a name="line.533"></a>
<span class="sourceLineNo">534</span><a name="line.534"></a>
<span class="sourceLineNo">535</span>    /**<a name="line.535"></a>
<span class="sourceLineNo">536</span>     * A list of overlays for the panel.<a name="line.536"></a>
<span class="sourceLineNo">537</span>     *<a name="line.537"></a>
<span class="sourceLineNo">538</span>     * @since 1.0.13<a name="line.538"></a>
<span class="sourceLineNo">539</span>     */<a name="line.539"></a>
<span class="sourceLineNo">540</span>    private List overlays;<a name="line.540"></a>
<span class="sourceLineNo">541</span><a name="line.541"></a>
<span class="sourceLineNo">542</span>    /**<a name="line.542"></a>
<span class="sourceLineNo">543</span>     * Constructs a panel that displays the specified chart.<a name="line.543"></a>
<span class="sourceLineNo">544</span>     *<a name="line.544"></a>
<span class="sourceLineNo">545</span>     * @param chart  the chart.<a name="line.545"></a>
<span class="sourceLineNo">546</span>     */<a name="line.546"></a>
<span class="sourceLineNo">547</span>    public ChartPanel(JFreeChart chart) {<a name="line.547"></a>
<span class="sourceLineNo">548</span><a name="line.548"></a>
<span class="sourceLineNo">549</span>        this(<a name="line.549"></a>
<span class="sourceLineNo">550</span>            chart,<a name="line.550"></a>
<span class="sourceLineNo">551</span>            DEFAULT_WIDTH,<a name="line.551"></a>
<span class="sourceLineNo">552</span>            DEFAULT_HEIGHT,<a name="line.552"></a>
<span class="sourceLineNo">553</span>            DEFAULT_MINIMUM_DRAW_WIDTH,<a name="line.553"></a>
<span class="sourceLineNo">554</span>            DEFAULT_MINIMUM_DRAW_HEIGHT,<a name="line.554"></a>
<span class="sourceLineNo">555</span>            DEFAULT_MAXIMUM_DRAW_WIDTH,<a name="line.555"></a>
<span class="sourceLineNo">556</span>            DEFAULT_MAXIMUM_DRAW_HEIGHT,<a name="line.556"></a>
<span class="sourceLineNo">557</span>            DEFAULT_BUFFER_USED,<a name="line.557"></a>
<span class="sourceLineNo">558</span>            true,  // properties<a name="line.558"></a>
<span class="sourceLineNo">559</span>            true,  // save<a name="line.559"></a>
<span class="sourceLineNo">560</span>            true,  // print<a name="line.560"></a>
<span class="sourceLineNo">561</span>            true,  // zoom<a name="line.561"></a>
<span class="sourceLineNo">562</span>            true   // tooltips<a name="line.562"></a>
<span class="sourceLineNo">563</span>        );<a name="line.563"></a>
<span class="sourceLineNo">564</span><a name="line.564"></a>
<span class="sourceLineNo">565</span>    }<a name="line.565"></a>
<span class="sourceLineNo">566</span><a name="line.566"></a>
<span class="sourceLineNo">567</span>    /**<a name="line.567"></a>
<span class="sourceLineNo">568</span>     * Constructs a panel containing a chart.  The &lt;code&gt;useBuffer&lt;/code&gt; flag<a name="line.568"></a>
<span class="sourceLineNo">569</span>     * controls whether or not an offscreen &lt;code&gt;BufferedImage&lt;/code&gt; is<a name="line.569"></a>
<span class="sourceLineNo">570</span>     * maintained for the chart.  If the buffer is used, more memory is<a name="line.570"></a>
<span class="sourceLineNo">571</span>     * consumed, but panel repaints will be a lot quicker in cases where the<a name="line.571"></a>
<span class="sourceLineNo">572</span>     * chart itself hasn't changed (for example, when another frame is moved<a name="line.572"></a>
<span class="sourceLineNo">573</span>     * to reveal the panel).  WARNING: If you set the &lt;code&gt;useBuffer&lt;/code&gt;<a name="line.573"></a>
<span class="sourceLineNo">574</span>     * flag to false, note that the mouse zooming rectangle will (in that case)<a name="line.574"></a>
<span class="sourceLineNo">575</span>     * be drawn using XOR, and there is a SEVERE performance problem with that<a name="line.575"></a>
<span class="sourceLineNo">576</span>     * on JRE6 on Windows.<a name="line.576"></a>
<span class="sourceLineNo">577</span>     *<a name="line.577"></a>
<span class="sourceLineNo">578</span>     * @param chart  the chart.<a name="line.578"></a>
<span class="sourceLineNo">579</span>     * @param useBuffer  a flag controlling whether or not an off-screen buffer<a name="line.579"></a>
<span class="sourceLineNo">580</span>     *                   is used (read the warning above before setting this<a name="line.580"></a>
<span class="sourceLineNo">581</span>     *                   to &lt;code&gt;false&lt;/code&gt;).<a name="line.581"></a>
<span class="sourceLineNo">582</span>     */<a name="line.582"></a>
<span class="sourceLineNo">583</span>    public ChartPanel(JFreeChart chart, boolean useBuffer) {<a name="line.583"></a>
<span class="sourceLineNo">584</span><a name="line.584"></a>
<span class="sourceLineNo">585</span>        this(chart, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH,<a name="line.585"></a>
<span class="sourceLineNo">586</span>                DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH,<a name="line.586"></a>
<span class="sourceLineNo">587</span>                DEFAULT_MAXIMUM_DRAW_HEIGHT, useBuffer,<a name="line.587"></a>
<span class="sourceLineNo">588</span>                true,  // properties<a name="line.588"></a>
<span class="sourceLineNo">589</span>                true,  // save<a name="line.589"></a>
<span class="sourceLineNo">590</span>                true,  // print<a name="line.590"></a>
<span class="sourceLineNo">591</span>                true,  // zoom<a name="line.591"></a>
<span class="sourceLineNo">592</span>                true   // tooltips<a name="line.592"></a>
<span class="sourceLineNo">593</span>                );<a name="line.593"></a>
<span class="sourceLineNo">594</span><a name="line.594"></a>
<span class="sourceLineNo">595</span>    }<a name="line.595"></a>
<span class="sourceLineNo">596</span><a name="line.596"></a>
<span class="sourceLineNo">597</span>    /**<a name="line.597"></a>
<span class="sourceLineNo">598</span>     * Constructs a JFreeChart panel.<a name="line.598"></a>
<span class="sourceLineNo">599</span>     *<a name="line.599"></a>
<span class="sourceLineNo">600</span>     * @param chart  the chart.<a name="line.600"></a>
<span class="sourceLineNo">601</span>     * @param properties  a flag indicating whether or not the chart property<a name="line.601"></a>
<span class="sourceLineNo">602</span>     *                    editor should be available via the popup menu.<a name="line.602"></a>
<span class="sourceLineNo">603</span>     * @param save  a flag indicating whether or not save options should be<a name="line.603"></a>
<span class="sourceLineNo">604</span>     *              available via the popup menu.<a name="line.604"></a>
<span class="sourceLineNo">605</span>     * @param print  a flag indicating whether or not the print option<a name="line.605"></a>
<span class="sourceLineNo">606</span>     *               should be available via the popup menu.<a name="line.606"></a>
<span class="sourceLineNo">607</span>     * @param zoom  a flag indicating whether or not zoom options should<a name="line.607"></a>
<span class="sourceLineNo">608</span>     *              be added to the popup menu.<a name="line.608"></a>
<span class="sourceLineNo">609</span>     * @param tooltips  a flag indicating whether or not tooltips should be<a name="line.609"></a>
<span class="sourceLineNo">610</span>     *                  enabled for the chart.<a name="line.610"></a>
<span class="sourceLineNo">611</span>     */<a name="line.611"></a>
<span class="sourceLineNo">612</span>    public ChartPanel(JFreeChart chart,<a name="line.612"></a>
<span class="sourceLineNo">613</span>                      boolean properties,<a name="line.613"></a>
<span class="sourceLineNo">614</span>                      boolean save,<a name="line.614"></a>
<span class="sourceLineNo">615</span>                      boolean print,<a name="line.615"></a>
<span class="sourceLineNo">616</span>                      boolean zoom,<a name="line.616"></a>
<span class="sourceLineNo">617</span>                      boolean tooltips) {<a name="line.617"></a>
<span class="sourceLineNo">618</span><a name="line.618"></a>
<span class="sourceLineNo">619</span>        this(chart,<a name="line.619"></a>
<span class="sourceLineNo">620</span>             DEFAULT_WIDTH,<a name="line.620"></a>
<span class="sourceLineNo">621</span>             DEFAULT_HEIGHT,<a name="line.621"></a>
<span class="sourceLineNo">622</span>             DEFAULT_MINIMUM_DRAW_WIDTH,<a name="line.622"></a>
<span class="sourceLineNo">623</span>             DEFAULT_MINIMUM_DRAW_HEIGHT,<a name="line.623"></a>
<span class="sourceLineNo">624</span>             DEFAULT_MAXIMUM_DRAW_WIDTH,<a name="line.624"></a>
<span class="sourceLineNo">625</span>             DEFAULT_MAXIMUM_DRAW_HEIGHT,<a name="line.625"></a>
<span class="sourceLineNo">626</span>             DEFAULT_BUFFER_USED,<a name="line.626"></a>
<span class="sourceLineNo">627</span>             properties,<a name="line.627"></a>
<span class="sourceLineNo">628</span>             save,<a name="line.628"></a>
<span class="sourceLineNo">629</span>             print,<a name="line.629"></a>
<span class="sourceLineNo">630</span>             zoom,<a name="line.630"></a>
<span class="sourceLineNo">631</span>             tooltips<a name="line.631"></a>
<span class="sourceLineNo">632</span>             );<a name="line.632"></a>
<span class="sourceLineNo">633</span><a name="line.633"></a>
<span class="sourceLineNo">634</span>    }<a name="line.634"></a>
<span class="sourceLineNo">635</span><a name="line.635"></a>
<span class="sourceLineNo">636</span>    /**<a name="line.636"></a>
<span class="sourceLineNo">637</span>     * Constructs a JFreeChart panel.<a name="line.637"></a>
<span class="sourceLineNo">638</span>     *<a name="line.638"></a>
<span class="sourceLineNo">639</span>     * @param chart  the chart.<a name="line.639"></a>
<span class="sourceLineNo">640</span>     * @param width  the preferred width of the panel.<a name="line.640"></a>
<span class="sourceLineNo">641</span>     * @param height  the preferred height of the panel.<a name="line.641"></a>
<span class="sourceLineNo">642</span>     * @param minimumDrawWidth  the minimum drawing width.<a name="line.642"></a>
<span class="sourceLineNo">643</span>     * @param minimumDrawHeight  the minimum drawing height.<a name="line.643"></a>
<span class="sourceLineNo">644</span>     * @param maximumDrawWidth  the maximum drawing width.<a name="line.644"></a>
<span class="sourceLineNo">645</span>     * @param maximumDrawHeight  the maximum drawing height.<a name="line.645"></a>
<span class="sourceLineNo">646</span>     * @param useBuffer  a flag that indicates whether to use the off-screen<a name="line.646"></a>
<span class="sourceLineNo">647</span>     *                   buffer to improve performance (at the expense of<a name="line.647"></a>
<span class="sourceLineNo">648</span>     *                   memory).<a name="line.648"></a>
<span class="sourceLineNo">649</span>     * @param properties  a flag indicating whether or not the chart property<a name="line.649"></a>
<span class="sourceLineNo">650</span>     *                    editor should be available via the popup menu.<a name="line.650"></a>
<span class="sourceLineNo">651</span>     * @param save  a flag indicating whether or not save options should be<a name="line.651"></a>
<span class="sourceLineNo">652</span>     *              available via the popup menu.<a name="line.652"></a>
<span class="sourceLineNo">653</span>     * @param print  a flag indicating whether or not the print option<a name="line.653"></a>
<span class="sourceLineNo">654</span>     *               should be available via the popup menu.<a name="line.654"></a>
<span class="sourceLineNo">655</span>     * @param zoom  a flag indicating whether or not zoom options should be<a name="line.655"></a>
<span class="sourceLineNo">656</span>     *              added to the popup menu.<a name="line.656"></a>
<span class="sourceLineNo">657</span>     * @param tooltips  a flag indicating whether or not tooltips should be<a name="line.657"></a>
<span class="sourceLineNo">658</span>     *                  enabled for the chart.<a name="line.658"></a>
<span class="sourceLineNo">659</span>     */<a name="line.659"></a>
<span class="sourceLineNo">660</span>    public ChartPanel(JFreeChart chart, int width, int height,<a name="line.660"></a>
<span class="sourceLineNo">661</span>            int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth,<a name="line.661"></a>
<span class="sourceLineNo">662</span>            int maximumDrawHeight, boolean useBuffer, boolean properties,<a name="line.662"></a>
<span class="sourceLineNo">663</span>            boolean save, boolean print, boolean zoom, boolean tooltips) {<a name="line.663"></a>
<span class="sourceLineNo">664</span><a name="line.664"></a>
<span class="sourceLineNo">665</span>        this(chart, width, height, minimumDrawWidth, minimumDrawHeight,<a name="line.665"></a>
<span class="sourceLineNo">666</span>                maximumDrawWidth, maximumDrawHeight, useBuffer, properties,<a name="line.666"></a>
<span class="sourceLineNo">667</span>                true, save, print, zoom, tooltips);<a name="line.667"></a>
<span class="sourceLineNo">668</span>    }<a name="line.668"></a>
<span class="sourceLineNo">669</span><a name="line.669"></a>
<span class="sourceLineNo">670</span>    /**<a name="line.670"></a>
<span class="sourceLineNo">671</span>     * Constructs a JFreeChart panel.<a name="line.671"></a>
<span class="sourceLineNo">672</span>     *<a name="line.672"></a>
<span class="sourceLineNo">673</span>     * @param chart  the chart.<a name="line.673"></a>
<span class="sourceLineNo">674</span>     * @param width  the preferred width of the panel.<a name="line.674"></a>
<span class="sourceLineNo">675</span>     * @param height  the preferred height of the panel.<a name="line.675"></a>
<span class="sourceLineNo">676</span>     * @param minimumDrawWidth  the minimum drawing width.<a name="line.676"></a>
<span class="sourceLineNo">677</span>     * @param minimumDrawHeight  the minimum drawing height.<a name="line.677"></a>
<span class="sourceLineNo">678</span>     * @param maximumDrawWidth  the maximum drawing width.<a name="line.678"></a>
<span class="sourceLineNo">679</span>     * @param maximumDrawHeight  the maximum drawing height.<a name="line.679"></a>
<span class="sourceLineNo">680</span>     * @param useBuffer  a flag that indicates whether to use the off-screen<a name="line.680"></a>
<span class="sourceLineNo">681</span>     *                   buffer to improve performance (at the expense of<a name="line.681"></a>
<span class="sourceLineNo">682</span>     *                   memory).<a name="line.682"></a>
<span class="sourceLineNo">683</span>     * @param properties  a flag indicating whether or not the chart property<a name="line.683"></a>
<span class="sourceLineNo">684</span>     *                    editor should be available via the popup menu.<a name="line.684"></a>
<span class="sourceLineNo">685</span>     * @param copy  a flag indicating whether or not a copy option should be<a name="line.685"></a>
<span class="sourceLineNo">686</span>     *              available via the popup menu.<a name="line.686"></a>
<span class="sourceLineNo">687</span>     * @param save  a flag indicating whether or not save options should be<a name="line.687"></a>
<span class="sourceLineNo">688</span>     *              available via the popup menu.<a name="line.688"></a>
<span class="sourceLineNo">689</span>     * @param print  a flag indicating whether or not the print option<a name="line.689"></a>
<span class="sourceLineNo">690</span>     *               should be available via the popup menu.<a name="line.690"></a>
<span class="sourceLineNo">691</span>     * @param zoom  a flag indicating whether or not zoom options should be<a name="line.691"></a>
<span class="sourceLineNo">692</span>     *              added to the popup menu.<a name="line.692"></a>
<span class="sourceLineNo">693</span>     * @param tooltips  a flag indicating whether or not tooltips should be<a name="line.693"></a>
<span class="sourceLineNo">694</span>     *                  enabled for the chart.<a name="line.694"></a>
<span class="sourceLineNo">695</span>     *<a name="line.695"></a>
<span class="sourceLineNo">696</span>     * @since 1.0.13<a name="line.696"></a>
<span class="sourceLineNo">697</span>     */<a name="line.697"></a>
<span class="sourceLineNo">698</span>    public ChartPanel(JFreeChart chart, int width, int height,<a name="line.698"></a>
<span class="sourceLineNo">699</span>           int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth,<a name="line.699"></a>
<span class="sourceLineNo">700</span>           int maximumDrawHeight, boolean useBuffer, boolean properties,<a name="line.700"></a>
<span class="sourceLineNo">701</span>           boolean copy, boolean save, boolean print, boolean zoom,<a name="line.701"></a>
<span class="sourceLineNo">702</span>           boolean tooltips) {<a name="line.702"></a>
<span class="sourceLineNo">703</span><a name="line.703"></a>
<span class="sourceLineNo">704</span>        setChart(chart);<a name="line.704"></a>
<span class="sourceLineNo">705</span>        this.chartMouseListeners = new EventListenerList();<a name="line.705"></a>
<span class="sourceLineNo">706</span>        this.info = new ChartRenderingInfo();<a name="line.706"></a>
<span class="sourceLineNo">707</span>        setPreferredSize(new Dimension(width, height));<a name="line.707"></a>
<span class="sourceLineNo">708</span>        this.useBuffer = useBuffer;<a name="line.708"></a>
<span class="sourceLineNo">709</span>        this.refreshBuffer = false;<a name="line.709"></a>
<span class="sourceLineNo">710</span>        this.minimumDrawWidth = minimumDrawWidth;<a name="line.710"></a>
<span class="sourceLineNo">711</span>        this.minimumDrawHeight = minimumDrawHeight;<a name="line.711"></a>
<span class="sourceLineNo">712</span>        this.maximumDrawWidth = maximumDrawWidth;<a name="line.712"></a>
<span class="sourceLineNo">713</span>        this.maximumDrawHeight = maximumDrawHeight;<a name="line.713"></a>
<span class="sourceLineNo">714</span>        this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE;<a name="line.714"></a>
<span class="sourceLineNo">715</span><a name="line.715"></a>
<span class="sourceLineNo">716</span>        // set up popup menu...<a name="line.716"></a>
<span class="sourceLineNo">717</span>        this.popup = null;<a name="line.717"></a>
<span class="sourceLineNo">718</span>        if (properties || copy || save || print || zoom) {<a name="line.718"></a>
<span class="sourceLineNo">719</span>            this.popup = createPopupMenu(properties, copy, save, print, zoom);<a name="line.719"></a>
<span class="sourceLineNo">720</span>        }<a name="line.720"></a>
<span class="sourceLineNo">721</span><a name="line.721"></a>
<span class="sourceLineNo">722</span>        enableEvents(AWTEvent.MOUSE_EVENT_MASK);<a name="line.722"></a>
<span class="sourceLineNo">723</span>        enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);<a name="line.723"></a>
<span class="sourceLineNo">724</span>        setDisplayToolTips(tooltips);<a name="line.724"></a>
<span class="sourceLineNo">725</span>        addMouseListener(this);<a name="line.725"></a>
<span class="sourceLineNo">726</span>        addMouseMotionListener(this);<a name="line.726"></a>
<span class="sourceLineNo">727</span><a name="line.727"></a>
<span class="sourceLineNo">728</span>        this.defaultDirectoryForSaveAs = null;<a name="line.728"></a>
<span class="sourceLineNo">729</span>        this.enforceFileExtensions = true;<a name="line.729"></a>
<span class="sourceLineNo">730</span><a name="line.730"></a>
<span class="sourceLineNo">731</span>        // initialize ChartPanel-specific tool tip delays with<a name="line.731"></a>
<span class="sourceLineNo">732</span>        // values the from ToolTipManager.sharedInstance()<a name="line.732"></a>
<span class="sourceLineNo">733</span>        ToolTipManager ttm = ToolTipManager.sharedInstance();<a name="line.733"></a>
<span class="sourceLineNo">734</span>        this.ownToolTipInitialDelay = ttm.getInitialDelay();<a name="line.734"></a>
<span class="sourceLineNo">735</span>        this.ownToolTipDismissDelay = ttm.getDismissDelay();<a name="line.735"></a>
<span class="sourceLineNo">736</span>        this.ownToolTipReshowDelay = ttm.getReshowDelay();<a name="line.736"></a>
<span class="sourceLineNo">737</span><a name="line.737"></a>
<span class="sourceLineNo">738</span>        this.zoomAroundAnchor = false;<a name="line.738"></a>
<span class="sourceLineNo">739</span>        this.zoomOutlinePaint = Color.blue;<a name="line.739"></a>
<span class="sourceLineNo">740</span>        this.zoomFillPaint = new Color(0, 0, 255, 63);<a name="line.740"></a>
<span class="sourceLineNo">741</span><a name="line.741"></a>
<span class="sourceLineNo">742</span>        this.panMask = InputEvent.CTRL_MASK;<a name="line.742"></a>
<span class="sourceLineNo">743</span>        // for MacOSX we can't use the CTRL key for mouse drags, see:<a name="line.743"></a>
<span class="sourceLineNo">744</span>        // http://developer.apple.com/qa/qa2004/qa1362.html<a name="line.744"></a>
<span class="sourceLineNo">745</span>        String osName = System.getProperty("os.name").toLowerCase();<a name="line.745"></a>
<span class="sourceLineNo">746</span>        if (osName.startsWith("mac os x")) {<a name="line.746"></a>
<span class="sourceLineNo">747</span>            this.panMask = InputEvent.ALT_MASK;<a name="line.747"></a>
<span class="sourceLineNo">748</span>        }<a name="line.748"></a>
<span class="sourceLineNo">749</span><a name="line.749"></a>
<span class="sourceLineNo">750</span>        this.overlays = new java.util.ArrayList();<a name="line.750"></a>
<span class="sourceLineNo">751</span>    }<a name="line.751"></a>
<span class="sourceLineNo">752</span><a name="line.752"></a>
<span class="sourceLineNo">753</span>    /**<a name="line.753"></a>
<span class="sourceLineNo">754</span>     * Returns the chart contained in the panel.<a name="line.754"></a>
<span class="sourceLineNo">755</span>     *<a name="line.755"></a>
<span class="sourceLineNo">756</span>     * @return The chart (possibly &lt;code&gt;null&lt;/code&gt;).<a name="line.756"></a>
<span class="sourceLineNo">757</span>     */<a name="line.757"></a>
<span class="sourceLineNo">758</span>    public JFreeChart getChart() {<a name="line.758"></a>
<span class="sourceLineNo">759</span>        return this.chart;<a name="line.759"></a>
<span class="sourceLineNo">760</span>    }<a name="line.760"></a>
<span class="sourceLineNo">761</span><a name="line.761"></a>
<span class="sourceLineNo">762</span>    /**<a name="line.762"></a>
<span class="sourceLineNo">763</span>     * Sets the chart that is displayed in the panel.<a name="line.763"></a>
<span class="sourceLineNo">764</span>     *<a name="line.764"></a>
<span class="sourceLineNo">765</span>     * @param chart  the chart (&lt;code&gt;null&lt;/code&gt; permitted).<a name="line.765"></a>
<span class="sourceLineNo">766</span>     */<a name="line.766"></a>
<span class="sourceLineNo">767</span>    public void setChart(JFreeChart chart) {<a name="line.767"></a>
<span class="sourceLineNo">768</span><a name="line.768"></a>
<span class="sourceLineNo">769</span>        // stop listening for changes to the existing chart<a name="line.769"></a>
<span class="sourceLineNo">770</span>        if (this.chart != null) {<a name="line.770"></a>
<span class="sourceLineNo">771</span>            this.chart.removeChangeListener(this);<a name="line.771"></a>
<span class="sourceLineNo">772</span>            this.chart.removeProgressListener(this);<a name="line.772"></a>
<span class="sourceLineNo">773</span>        }<a name="line.773"></a>
<span class="sourceLineNo">774</span><a name="line.774"></a>
<span class="sourceLineNo">775</span>        // add the new chart<a name="line.775"></a>
<span class="sourceLineNo">776</span>        this.chart = chart;<a name="line.776"></a>
<span class="sourceLineNo">777</span>        if (chart != null) {<a name="line.777"></a>
<span class="sourceLineNo">778</span>            this.chart.addChangeListener(this);<a name="line.778"></a>
<span class="sourceLineNo">779</span>            this.chart.addProgressListener(this);<a name="line.779"></a>
<span class="sourceLineNo">780</span>            Plot plot = chart.getPlot();<a name="line.780"></a>
<span class="sourceLineNo">781</span>            this.domainZoomable = false;<a name="line.781"></a>
<span class="sourceLineNo">782</span>            this.rangeZoomable = false;<a name="line.782"></a>
<span class="sourceLineNo">783</span>            if (plot instanceof Zoomable) {<a name="line.783"></a>
<span class="sourceLineNo">784</span>                Zoomable z = (Zoomable) plot;<a name="line.784"></a>
<span class="sourceLineNo">785</span>                this.domainZoomable = z.isDomainZoomable();<a name="line.785"></a>
<span class="sourceLineNo">786</span>                this.rangeZoomable = z.isRangeZoomable();<a name="line.786"></a>
<span class="sourceLineNo">787</span>                this.orientation = z.getOrientation();<a name="line.787"></a>
<span class="sourceLineNo">788</span>            }<a name="line.788"></a>
<span class="sourceLineNo">789</span>        }<a name="line.789"></a>
<span class="sourceLineNo">790</span>        else {<a name="line.790"></a>
<span class="sourceLineNo">791</span>            this.domainZoomable = false;<a name="line.791"></a>
<span class="sourceLineNo">792</span>            this.rangeZoomable = false;<a name="line.792"></a>
<span class="sourceLineNo">793</span>        }<a name="line.793"></a>
<span class="sourceLineNo">794</span>        if (this.useBuffer) {<a name="line.794"></a>
<span class="sourceLineNo">795</span>            this.refreshBuffer = true;<a name="line.795"></a>
<span class="sourceLineNo">796</span>        }<a name="line.796"></a>
<span class="sourceLineNo">797</span>        repaint();<a name="line.797"></a>
<span class="sourceLineNo">798</span><a name="line.798"></a>
<span class="sourceLineNo">799</span>    }<a name="line.799"></a>
<span class="sourceLineNo">800</span><a name="line.800"></a>
<span class="sourceLineNo">801</span>    /**<a name="line.801"></a>
<span class="sourceLineNo">802</span>     * Returns the minimum drawing width for charts.<a name="line.802"></a>
<span class="sourceLineNo">803</span>     * &lt;P&gt;<a name="line.803"></a>
<span class="sourceLineNo">804</span>     * If the width available on the panel is less than this, then the chart is<a name="line.804"></a>
<span class="sourceLineNo">805</span>     * drawn at the minimum width then scaled down to fit.<a name="line.805"></a>
<span class="sourceLineNo">806</span>     *<a name="line.806"></a>
<span class="sourceLineNo">807</span>     * @return The minimum drawing width.<a name="line.807"></a>
<span class="sourceLineNo">808</span>     */<a name="line.808"></a>
<span class="sourceLineNo">809</span>    public int getMinimumDrawWidth() {<a name="line.809"></a>
<span class="sourceLineNo">810</span>        return this.minimumDrawWidth;<a name="line.810"></a>
<span class="sourceLineNo">811</span>    }<a name="line.811"></a>
<span class="sourceLineNo">812</span><a name="line.812"></a>
<span class="sourceLineNo">813</span>    /**<a name="line.813"></a>
<span class="sourceLineNo">814</span>     * Sets the minimum drawing width for the chart on this panel.<a name="line.814"></a>
<span class="sourceLineNo">815</span>     * &lt;P&gt;<a name="line.815"></a>
<span class="sourceLineNo">816</span>     * At the time the chart is drawn on the panel, if the available width is<a name="line.816"></a>
<span class="sourceLineNo">817</span>     * less than this amount, the chart will be drawn using the minimum width<a name="line.817"></a>
<span class="sourceLineNo">818</span>     * then scaled down to fit the available space.<a name="line.818"></a>
<span class="sourceLineNo">819</span>     *<a name="line.819"></a>
<span class="sourceLineNo">820</span>     * @param width  The width.<a name="line.820"></a>
<span class="sourceLineNo">821</span>     */<a name="line.821"></a>
<span class="sourceLineNo">822</span>    public void setMinimumDrawWidth(int width) {<a name="line.822"></a>
<span class="sourceLineNo">823</span>        this.minimumDrawWidth = width;<a name="line.823"></a>
<span class="sourceLineNo">824</span>    }<a name="line.824"></a>
<span class="sourceLineNo">825</span><a name="line.825"></a>
<span class="sourceLineNo">826</span>    /**<a name="line.826"></a>
<span class="sourceLineNo">827</span>     * Returns the maximum drawing width for charts.<a name="line.827"></a>
<span class="sourceLineNo">828</span>     * &lt;P&gt;<a name="line.828"></a>
<span class="sourceLineNo">829</span>     * If the width available on the panel is greater than this, then the chart<a name="line.829"></a>
<span class="sourceLineNo">830</span>     * is drawn at the maximum width then scaled up to fit.<a name="line.830"></a>
<span class="sourceLineNo">831</span>     *<a name="line.831"></a>
<span class="sourceLineNo">832</span>     * @return The maximum drawing width.<a name="line.832"></a>
<span class="sourceLineNo">833</span>     */<a name="line.833"></a>
<span class="sourceLineNo">834</span>    public int getMaximumDrawWidth() {<a name="line.834"></a>
<span class="sourceLineNo">835</span>        return this.maximumDrawWidth;<a name="line.835"></a>
<span class="sourceLineNo">836</span>    }<a name="line.836"></a>
<span class="sourceLineNo">837</span><a name="line.837"></a>
<span class="sourceLineNo">838</span>    /**<a name="line.838"></a>
<span class="sourceLineNo">839</span>     * Sets the maximum drawing width for the chart on this panel.<a name="line.839"></a>
<span class="sourceLineNo">840</span>     * &lt;P&gt;<a name="line.840"></a>
<span class="sourceLineNo">841</span>     * At the time the chart is drawn on the panel, if the available width is<a name="line.841"></a>
<span class="sourceLineNo">842</span>     * greater than this amount, the chart will be drawn using the maximum<a name="line.842"></a>
<span class="sourceLineNo">843</span>     * width then scaled up to fit the available space.<a name="line.843"></a>
<span class="sourceLineNo">844</span>     *<a name="line.844"></a>
<span class="sourceLineNo">845</span>     * @param width  The width.<a name="line.845"></a>
<span class="sourceLineNo">846</span>     */<a name="line.846"></a>
<span class="sourceLineNo">847</span>    public void setMaximumDrawWidth(int width) {<a name="line.847"></a>
<span class="sourceLineNo">848</span>        this.maximumDrawWidth = width;<a name="line.848"></a>
<span class="sourceLineNo">849</span>    }<a name="line.849"></a>
<span class="sourceLineNo">850</span><a name="line.850"></a>
<span class="sourceLineNo">851</span>    /**<a name="line.851"></a>
<span class="sourceLineNo">852</span>     * Returns the minimum drawing height for charts.<a name="line.852"></a>
<span class="sourceLineNo">853</span>     * &lt;P&gt;<a name="line.853"></a>
<span class="sourceLineNo">854</span>     * If the height available on the panel is less than this, then the chart<a name="line.854"></a>
<span class="sourceLineNo">855</span>     * is drawn at the minimum height then scaled down to fit.<a name="line.855"></a>
<span class="sourceLineNo">856</span>     *<a name="line.856"></a>
<span class="sourceLineNo">857</span>     * @return The minimum drawing height.<a name="line.857"></a>
<span class="sourceLineNo">858</span>     */<a name="line.858"></a>
<span class="sourceLineNo">859</span>    public int getMinimumDrawHeight() {<a name="line.859"></a>
<span class="sourceLineNo">860</span>        return this.minimumDrawHeight;<a name="line.860"></a>
<span class="sourceLineNo">861</span>    }<a name="line.861"></a>
<span class="sourceLineNo">862</span><a name="line.862"></a>
<span class="sourceLineNo">863</span>    /**<a name="line.863"></a>
<span class="sourceLineNo">864</span>     * Sets the minimum drawing height for the chart on this panel.<a name="line.864"></a>
<span class="sourceLineNo">865</span>     * &lt;P&gt;<a name="line.865"></a>
<span class="sourceLineNo">866</span>     * At the time the chart is drawn on the panel, if the available height is<a name="line.866"></a>
<span class="sourceLineNo">867</span>     * less than this amount, the chart will be drawn using the minimum height<a name="line.867"></a>
<span class="sourceLineNo">868</span>     * then scaled down to fit the available space.<a name="line.868"></a>
<span class="sourceLineNo">869</span>     *<a name="line.869"></a>
<span class="sourceLineNo">870</span>     * @param height  The height.<a name="line.870"></a>
<span class="sourceLineNo">871</span>     */<a name="line.871"></a>
<span class="sourceLineNo">872</span>    public void setMinimumDrawHeight(int height) {<a name="line.872"></a>
<span class="sourceLineNo">873</span>        this.minimumDrawHeight = height;<a name="line.873"></a>
<span class="sourceLineNo">874</span>    }<a name="line.874"></a>
<span class="sourceLineNo">875</span><a name="line.875"></a>
<span class="sourceLineNo">876</span>    /**<a name="line.876"></a>
<span class="sourceLineNo">877</span>     * Returns the maximum drawing height for charts.<a name="line.877"></a>
<span class="sourceLineNo">878</span>     * &lt;P&gt;<a name="line.878"></a>
<span class="sourceLineNo">879</span>     * If the height available on the panel is greater than this, then the<a name="line.879"></a>
<span class="sourceLineNo">880</span>     * chart is drawn at the maximum height then scaled up to fit.<a name="line.880"></a>
<span class="sourceLineNo">881</span>     *<a name="line.881"></a>
<span class="sourceLineNo">882</span>     * @return The maximum drawing height.<a name="line.882"></a>
<span class="sourceLineNo">883</span>     */<a name="line.883"></a>
<span class="sourceLineNo">884</span>    public int getMaximumDrawHeight() {<a name="line.884"></a>
<span class="sourceLineNo">885</span>        return this.maximumDrawHeight;<a name="line.885"></a>
<span class="sourceLineNo">886</span>    }<a name="line.886"></a>
<span class="sourceLineNo">887</span><a name="line.887"></a>
<span class="sourceLineNo">888</span>    /**<a name="line.888"></a>
<span class="sourceLineNo">889</span>     * Sets the maximum drawing height for the chart on this panel.<a name="line.889"></a>
<span class="sourceLineNo">890</span>     * &lt;P&gt;<a name="line.890"></a>
<span class="sourceLineNo">891</span>     * At the time the chart is drawn on the panel, if the available height is<a name="line.891"></a>
<span class="sourceLineNo">892</span>     * greater than this amount, the chart will be drawn using the maximum<a name="line.892"></a>
<span class="sourceLineNo">893</span>     * height then scaled up to fit the available space.<a name="line.893"></a>
<span class="sourceLineNo">894</span>     *<a name="line.894"></a>
<span class="sourceLineNo">895</span>     * @param height  The height.<a name="line.895"></a>
<span class="sourceLineNo">896</span>     */<a name="line.896"></a>
<span class="sourceLineNo">897</span>    public void setMaximumDrawHeight(int height) {<a name="line.897"></a>
<span class="sourceLineNo">898</span>        this.maximumDrawHeight = height;<a name="line.898"></a>
<span class="sourceLineNo">899</span>    }<a name="line.899"></a>
<span class="sourceLineNo">900</span><a name="line.900"></a>
<span class="sourceLineNo">901</span>    /**<a name="line.901"></a>
<span class="sourceLineNo">902</span>     * Returns the X scale factor for the chart.  This will be 1.0 if no<a name="line.902"></a>
<span class="sourceLineNo">903</span>     * scaling has been used.<a name="line.903"></a>
<span class="sourceLineNo">904</span>     *<a name="line.904"></a>
<span class="sourceLineNo">905</span>     * @return The scale factor.<a name="line.905"></a>
<span class="sourceLineNo">906</span>     */<a name="line.906"></a>
<span class="sourceLineNo">907</span>    public double getScaleX() {<a name="line.907"></a>
<span class="sourceLineNo">908</span>        return this.scaleX;<a name="line.908"></a>
<span class="sourceLineNo">909</span>    }<a name="line.909"></a>
<span class="sourceLineNo">910</span><a name="line.910"></a>
<span class="sourceLineNo">911</span>    /**<a name="line.911"></a>
<span class="sourceLineNo">912</span>     * Returns the Y scale factory for the chart.  This will be 1.0 if no<a name="line.912"></a>
<span class="sourceLineNo">913</span>     * scaling has been used.<a name="line.913"></a>
<span class="sourceLineNo">914</span>     *<a name="line.914"></a>
<span class="sourceLineNo">915</span>     * @return The scale factor.<a name="line.915"></a>
<span class="sourceLineNo">916</span>     */<a name="line.916"></a>
<span class="sourceLineNo">917</span>    public double getScaleY() {<a name="line.917"></a>
<span class="sourceLineNo">918</span>        return this.scaleY;<a name="line.918"></a>
<span class="sourceLineNo">919</span>    }<a name="line.919"></a>
<span class="sourceLineNo">920</span><a name="line.920"></a>
<span class="sourceLineNo">921</span>    /**<a name="line.921"></a>
<span class="sourceLineNo">922</span>     * Returns the anchor point.<a name="line.922"></a>
<span class="sourceLineNo">923</span>     *<a name="line.923"></a>
<span class="sourceLineNo">924</span>     * @return The anchor point (possibly &lt;code&gt;null&lt;/code&gt;).<a name="line.924"></a>
<span class="sourceLineNo">925</span>     */<a name="line.925"></a>
<span class="sourceLineNo">926</span>    public Point2D getAnchor() {<a name="line.926"></a>
<span class="sourceLineNo">927</span>        return this.anchor;<a name="line.927"></a>
<span class="sourceLineNo">928</span>    }<a name="line.928"></a>
<span class="sourceLineNo">929</span><a name="line.929"></a>
<span class="sourceLineNo">930</span>    /**<a name="line.930"></a>
<span class="sourceLineNo">931</span>     * Sets the anchor point.  This method is provided for the use of<a name="line.931"></a>
<span class="sourceLineNo">932</span>     * subclasses, not end users.<a name="line.932"></a>
<span class="sourceLineNo">933</span>     *<a name="line.933"></a>
<span class="sourceLineNo">934</span>     * @param anchor  the anchor point (&lt;code&gt;null&lt;/code&gt; permitted).<a name="line.934"></a>
<span class="sourceLineNo">935</span>     */<a name="line.935"></a>
<span class="sourceLineNo">936</span>    protected void setAnchor(Point2D anchor) {<a name="line.936"></a>
<span class="sourceLineNo">937</span>        this.anchor = anchor;<a name="line.937"></a>
<span class="sourceLineNo">938</span>    }<a name="line.938"></a>
<span class="sourceLineNo">939</span><a name="line.939"></a>
<span class="sourceLineNo">940</span>    /**<a name="line.940"></a>
<span class="sourceLineNo">941</span>     * Returns the popup menu.<a name="line.941"></a>
<span class="sourceLineNo">942</span>     *<a name="line.942"></a>
<span class="sourceLineNo">943</span>     * @return The popup menu.<a name="line.943"></a>
<span class="sourceLineNo">944</span>     */<a name="line.944"></a>
<span class="sourceLineNo">945</span>    public JPopupMenu getPopupMenu() {<a name="line.945"></a>
<span class="sourceLineNo">946</span>        return this.popup;<a name="line.946"></a>
<span class="sourceLineNo">947</span>    }<a name="line.947"></a>
<span class="sourceLineNo">948</span><a name="line.948"></a>
<span class="sourceLineNo">949</span>    /**<a name="line.949"></a>
<span class="sourceLineNo">950</span>     * Sets the popup menu for the panel.<a name="line.950"></a>
<span class="sourceLineNo">951</span>     *<a name="line.951"></a>
<span class="sourceLineNo">952</span>     * @param popup  the popup menu (&lt;code&gt;null&lt;/code&gt; permitted).<a name="line.952"></a>
<span class="sourceLineNo">953</span>     */<a name="line.953"></a>
<span class="sourceLineNo">954</span>    public void setPopupMenu(JPopupMenu popup) {<a name="line.954"></a>
<span class="sourceLineNo">955</span>        this.popup = popup;<a name="line.955"></a>
<span class="sourceLineNo">956</span>    }<a name="line.956"></a>
<span class="sourceLineNo">957</span><a name="line.957"></a>
<span class="sourceLineNo">958</span>    /**<a name="line.958"></a>
<span class="sourceLineNo">959</span>     * Returns the chart rendering info from the most recent chart redraw.<a name="line.959"></a>
<span class="sourceLineNo">960</span>     *<a name="line.960"></a>
<span class="sourceLineNo">961</span>     * @return The chart rendering info.<a name="line.961"></a>
<span class="sourceLineNo">962</span>     */<a name="line.962"></a>
<span class="sourceLineNo">963</span>    public ChartRenderingInfo getChartRenderingInfo() {<a name="line.963"></a>
<span class="sourceLineNo">964</span>        return this.info;<a name="line.964"></a>
<span class="sourceLineNo">965</span>    }<a name="line.965"></a>
<span class="sourceLineNo">966</span><a name="line.966"></a>
<span class="sourceLineNo">967</span>    /**<a name="line.967"></a>
<span class="sourceLineNo">968</span>     * A convenience method that switches on mouse-based zooming.<a name="line.968"></a>
<span class="sourceLineNo">969</span>     *<a name="line.969"></a>
<span class="sourceLineNo">970</span>     * @param flag  &lt;code&gt;true&lt;/code&gt; enables zooming and rectangle fill on<a name="line.970"></a>
<span class="sourceLineNo">971</span>     *              zoom.<a name="line.971"></a>
<span class="sourceLineNo">972</span>     */<a name="line.972"></a>
<span class="sourceLineNo">973</span>    public void setMouseZoomable(boolean flag) {<a name="line.973"></a>
<span class="sourceLineNo">974</span>        setMouseZoomable(flag, true);<a name="line.974"></a>
<span class="sourceLineNo">975</span>    }<a name="line.975"></a>
<span class="sourceLineNo">976</span><a name="line.976"></a>
<span class="sourceLineNo">977</span>    /**<a name="line.977"></a>
<span class="sourceLineNo">978</span>     * A convenience method that switches on mouse-based zooming.<a name="line.978"></a>
<span class="sourceLineNo">979</span>     *<a name="line.979"></a>
<span class="sourceLineNo">980</span>     * @param flag  &lt;code&gt;true&lt;/code&gt; if zooming enabled<a name="line.980"></a>
<span class="sourceLineNo">981</span>     * @param fillRectangle  &lt;code&gt;true&lt;/code&gt; if zoom rectangle is filled,<a name="line.981"></a>
<span class="sourceLineNo">982</span>     *                       false if rectangle is shown as outline only.<a name="line.982"></a>
<span class="sourceLineNo">983</span>     */<a name="line.983"></a>
<span class="sourceLineNo">984</span>    public void setMouseZoomable(boolean flag, boolean fillRectangle) {<a name="line.984"></a>
<span class="sourceLineNo">985</span>        setDomainZoomable(flag);<a name="line.985"></a>
<span class="sourceLineNo">986</span>        setRangeZoomable(flag);<a name="line.986"></a>
<span class="sourceLineNo">987</span>        setFillZoomRectangle(fillRectangle);<a name="line.987"></a>
<span class="sourceLineNo">988</span>    }<a name="line.988"></a>
<span class="sourceLineNo">989</span><a name="line.989"></a>
<span class="sourceLineNo">990</span>    /**<a name="line.990"></a>
<span class="sourceLineNo">991</span>     * Returns the flag that determines whether or not zooming is enabled for<a name="line.991"></a>
<span class="sourceLineNo">992</span>     * the domain axis.<a name="line.992"></a>
<span class="sourceLineNo">993</span>     *<a name="line.993"></a>
<span class="sourceLineNo">994</span>     * @return A boolean.<a name="line.994"></a>
<span class="sourceLineNo">995</span>     */<a name="line.995"></a>
<span class="sourceLineNo">996</span>    public boolean isDomainZoomable() {<a name="line.996"></a>
<span class="sourceLineNo">997</span>        return this.domainZoomable;<a name="line.997"></a>
<span class="sourceLineNo">998</span>    }<a name="line.998"></a>
<span class="sourceLineNo">999</span><a name="line.999"></a>
<span class="sourceLineNo">1000</span>    /**<a name="line.1000"></a>
<span class="sourceLineNo">1001</span>     * Sets the flag that controls whether or not zooming is enable for the<a name="line.1001"></a>
<span class="sourceLineNo">1002</span>     * domain axis.  A check is made to ensure that the current plot supports<a name="line.1002"></a>
<span class="sourceLineNo">1003</span>     * zooming for the domain values.<a name="line.1003"></a>
<span class="sourceLineNo">1004</span>     *<a name="line.1004"></a>
<span class="sourceLineNo">1005</span>     * @param flag  &lt;code&gt;true&lt;/code&gt; enables zooming if possible.<a name="line.1005"></a>
<span class="sourceLineNo">1006</span>     */<a name="line.1006"></a>
<span class="sourceLineNo">1007</span>    public void setDomainZoomable(boolean flag) {<a name="line.1007"></a>
<span class="sourceLineNo">1008</span>        if (flag) {<a name="line.1008"></a>
<span class="sourceLineNo">1009</span>            Plot plot = this.chart.getPlot();<a name="line.1009"></a>
<span class="sourceLineNo">1010</span>            if (plot instanceof Zoomable) {<a name="line.1010"></a>
<span class="sourceLineNo">1011</span>                Zoomable z = (Zoomable) plot;<a name="line.1011"></a>
<span class="sourceLineNo">1012</span>                this.domainZoomable = flag &amp;&amp; (z.isDomainZoomable());<a name="line.1012"></a>
<span class="sourceLineNo">1013</span>            }<a name="line.1013"></a>
<span class="sourceLineNo">1014</span>        }<a name="line.1014"></a>
<span class="sourceLineNo">1015</span>        else {<a name="line.1015"></a>
<span class="sourceLineNo">1016</span>            this.domainZoomable = false;<a name="line.1016"></a>
<span class="sourceLineNo">1017</span>        }<a name="line.1017"></a>
<span class="sourceLineNo">1018</span>    }<a name="line.1018"></a>
<span class="sourceLineNo">1019</span><a name="line.1019"></a>
<span class="sourceLineNo">1020</span>    /**<a name="line.1020"></a>
<span class="sourceLineNo">1021</span>     * Returns the flag that determines whether or not zooming is enabled for<a name="line.1021"></a>
<span class="sourceLineNo">1022</span>     * the range axis.<a name="line.1022"></a>
<span class="sourceLineNo">1023</span>     *<a name="line.1023"></a>
<span class="sourceLineNo">1024</span>     * @return A boolean.<a name="line.1024"></a>
<span class="sourceLineNo">1025</span>     */<a name="line.1025"></a>
<span class="sourceLineNo">1026</span>    public boolean isRangeZoomable() {<a name="line.1026"></a>
<span class="sourceLineNo">1027</span>        return this.rangeZoomable;<a name="line.1027"></a>
<span class="sourceLineNo">1028</span>    }<a name="line.1028"></a>
<span class="sourceLineNo">1029</span><a name="line.1029"></a>
<span class="sourceLineNo">1030</span>    /**<a name="line.1030"></a>
<span class="sourceLineNo">1031</span>     * A flag that controls mouse-based zooming on the vertical axis.<a name="line.1031"></a>
<span class="sourceLineNo">1032</span>     *<a name="line.1032"></a>
<span class="sourceLineNo">1033</span>     * @param flag  &lt;code&gt;true&lt;/code&gt; enables zooming.<a name="line.1033"></a>
<span class="sourceLineNo">1034</span>     */<a name="line.1034"></a>
<span class="sourceLineNo">1035</span>    public void setRangeZoomable(boolean flag) {<a name="line.1035"></a>
<span class="sourceLineNo">1036</span>        if (flag) {<a name="line.1036"></a>
<span class="sourceLineNo">1037</span>            Plot plot = this.chart.getPlot();<a name="line.1037"></a>
<span class="sourceLineNo">1038</span>            if (plot instanceof Zoomable) {<a name="line.1038"></a>
<span class="sourceLineNo">1039</span>                Zoomable z = (Zoomable) plot;<a name="line.1039"></a>
<span class="sourceLineNo">1040</span>                this.rangeZoomable = flag &amp;&amp; (z.isRangeZoomable());<a name="line.1040"></a>
<span class="sourceLineNo">1041</span>            }<a name="line.1041"></a>
<span class="sourceLineNo">1042</span>        }<a name="line.1042"></a>
<span class="sourceLineNo">1043</span>        else {<a name="line.1043"></a>
<span class="sourceLineNo">1044</span>            this.rangeZoomable = false;<a name="line.1044"></a>
<span class="sourceLineNo">1045</span>        }<a name="line.1045"></a>
<span class="sourceLineNo">1046</span>    }<a name="line.1046"></a>
<span class="sourceLineNo">1047</span><a name="line.1047"></a>
<span class="sourceLineNo">1048</span>    /**<a name="line.1048"></a>
<span class="sourceLineNo">1049</span>     * Returns the flag that controls whether or not the zoom rectangle is<a name="line.1049"></a>
<span class="sourceLineNo">1050</span>     * filled when drawn.<a name="line.1050"></a>
<span class="sourceLineNo">1051</span>     *<a name="line.1051"></a>
<span class="sourceLineNo">1052</span>     * @return A boolean.<a name="line.1052"></a>
<span class="sourceLineNo">1053</span>     */<a name="line.1053"></a>
<span class="sourceLineNo">1054</span>    public boolean getFillZoomRectangle() {<a name="line.1054"></a>
<span class="sourceLineNo">1055</span>        return this.fillZoomRectangle;<a name="line.1055"></a>
<span class="sourceLineNo">1056</span>    }<a name="line.1056"></a>
<span class="sourceLineNo">1057</span><a name="line.1057"></a>
<span class="sourceLineNo">1058</span>    /**<a name="line.1058"></a>
<span class="sourceLineNo">1059</span>     * A flag that controls how the zoom rectangle is drawn.<a name="line.1059"></a>
<span class="sourceLineNo">1060</span>     *<a name="line.1060"></a>
<span class="sourceLineNo">1061</span>     * @param flag  &lt;code&gt;true&lt;/code&gt; instructs to fill the rectangle on<a name="line.1061"></a>
<span class="sourceLineNo">1062</span>     *              zoom, otherwise it will be outlined.<a name="line.1062"></a>
<span class="sourceLineNo">1063</span>     */<a name="line.1063"></a>
<span class="sourceLineNo">1064</span>    public void setFillZoomRectangle(boolean flag) {<a name="line.1064"></a>
<span class="sourceLineNo">1065</span>        this.fillZoomRectangle = flag;<a name="line.1065"></a>
<span class="sourceLineNo">1066</span>    }<a name="line.1066"></a>
<span class="sourceLineNo">1067</span><a name="line.1067"></a>
<span class="sourceLineNo">1068</span>    /**<a name="line.1068"></a>
<span class="sourceLineNo">1069</span>     * Returns the zoom trigger distance.  This controls how far the mouse must<a name="line.1069"></a>
<span class="sourceLineNo">1070</span>     * move before a zoom action is triggered.<a name="line.1070"></a>
<span class="sourceLineNo">1071</span>     *<a name="line.1071"></a>
<span class="sourceLineNo">1072</span>     * @return The distance (in Java2D units).<a name="line.1072"></a>
<span class="sourceLineNo">1073</span>     */<a name="line.1073"></a>
<span class="sourceLineNo">1074</span>    public int getZoomTriggerDistance() {<a name="line.1074"></a>
<span class="sourceLineNo">1075</span>        return this.zoomTriggerDistance;<a name="line.1075"></a>
<span class="sourceLineNo">1076</span>    }<a name="line.1076"></a>
<span class="sourceLineNo">1077</span><a name="line.1077"></a>
<span class="sourceLineNo">1078</span>    /**<a name="line.1078"></a>
<span class="sourceLineNo">1079</span>     * Sets the zoom trigger distance.  This controls how far the mouse must<a name="line.1079"></a>
<span class="sourceLineNo">1080</span>     * move before a zoom action is triggered.<a name="line.1080"></a>
<span class="sourceLineNo">1081</span>     *<a name="line.1081"></a>
<span class="sourceLineNo">1082</span>     * @param distance  the distance (in Java2D units).<a name="line.1082"></a>
<span class="sourceLineNo">1083</span>     */<a name="line.1083"></a>
<span class="sourceLineNo">1084</span>    public void setZoomTriggerDistance(int distance) {<a name="line.1084"></a>
<span class="sourceLineNo">1085</span>        this.zoomTriggerDistance = distance;<a name="line.1085"></a>
<span class="sourceLineNo">1086</span>    }<a name="line.1086"></a>
<span class="sourceLineNo">1087</span><a name="line.1087"></a>
<span class="sourceLineNo">1088</span>    /**<a name="line.1088"></a>
<span class="sourceLineNo">1089</span>     * Returns the flag that controls whether or not a horizontal axis trace<a name="line.1089"></a>
<span class="sourceLineNo">1090</span>     * line is drawn over the plot area at the current mouse location.<a name="line.1090"></a>
<span class="sourceLineNo">1091</span>     *<a name="line.1091"></a>
<span class="sourceLineNo">1092</span>     * @return A boolean.<a name="line.1092"></a>
<span class="sourceLineNo">1093</span>     */<a name="line.1093"></a>
<span class="sourceLineNo">1094</span>    public boolean getHorizontalAxisTrace() {<a name="line.1094"></a>
<span class="sourceLineNo">1095</span>        return this.horizontalAxisTrace;<a name="line.1095"></a>
<span class="sourceLineNo">1096</span>    }<a name="line.1096"></a>
<span class="sourceLineNo">1097</span><a name="line.1097"></a>
<span class="sourceLineNo">1098</span>    /**<a name="line.1098"></a>
<span class="sourceLineNo">1099</span>     * A flag that controls trace lines on the horizontal axis.<a name="line.1099"></a>
<span class="sourceLineNo">1100</span>     *<a name="line.1100"></a>
<span class="sourceLineNo">1101</span>     * @param flag  &lt;code&gt;true&lt;/code&gt; enables trace lines for the mouse<a name="line.1101"></a>
<span class="sourceLineNo">1102</span>     *      pointer on the horizontal axis.<a name="line.1102"></a>
<span class="sourceLineNo">1103</span>     */<a name="line.1103"></a>
<span class="sourceLineNo">1104</span>    public void setHorizontalAxisTrace(boolean flag) {<a name="line.1104"></a>
<span class="sourceLineNo">1105</span>        this.horizontalAxisTrace = flag;<a name="line.1105"></a>
<span class="sourceLineNo">1106</span>    }<a name="line.1106"></a>
<span class="sourceLineNo">1107</span><a name="line.1107"></a>
<span class="sourceLineNo">1108</span>    /**<a name="line.1108"></a>
<span class="sourceLineNo">1109</span>     * Returns the horizontal trace line.<a name="line.1109"></a>
<span class="sourceLineNo">1110</span>     *<a name="line.1110"></a>
<span class="sourceLineNo">1111</span>     * @return The horizontal trace line (possibly &lt;code&gt;null&lt;/code&gt;).<a name="line.1111"></a>
<span class="sourceLineNo">1112</span>     */<a name="line.1112"></a>
<span class="sourceLineNo">1113</span>    protected Line2D getHorizontalTraceLine() {<a name="line.1113"></a>
<span class="sourceLineNo">1114</span>        return this.horizontalTraceLine;<a name="line.1114"></a>
<span class="sourceLineNo">1115</span>    }<a name="line.1115"></a>
<span class="sourceLineNo">1116</span><a name="line.1116"></a>
<span class="sourceLineNo">1117</span>    /**<a name="line.1117"></a>
<span class="sourceLineNo">1118</span>     * Sets the horizontal trace line.<a name="line.1118"></a>
<span class="sourceLineNo">1119</span>     *<a name="line.1119"></a>
<span class="sourceLineNo">1120</span>     * @param line  the line (&lt;code&gt;null&lt;/code&gt; permitted).<a name="line.1120"></a>
<span class="sourceLineNo">1121</span>     */<a name="line.1121"></a>
<span class="sourceLineNo">1122</span>    protected void setHorizontalTraceLine(Line2D line) {<a name="line.1122"></a>
<span class="sourceLineNo">1123</span>        this.horizontalTraceLine = line;<a name="line.1123"></a>
<span class="sourceLineNo">1124</span>    }<a name="line.1124"></a>
<span class="sourceLineNo">1125</span><a name="line.1125"></a>
<span class="sourceLineNo">1126</span>    /**<a name="line.1126"></a>
<span class="sourceLineNo">1127</span>     * Returns the flag that controls whether or not a vertical axis trace<a name="line.1127"></a>
<span class="sourceLineNo">1128</span>     * line is drawn over the plot area at the current mouse location.<a name="line.1128"></a>
<span class="sourceLineNo">1129</span>     *<a name="line.1129"></a>
<span class="sourceLineNo">1130</span>     * @return A boolean.<a name="line.1130"></a>
<span class="sourceLineNo">1131</span>     */<a name="line.1131"></a>
<span class="sourceLineNo">1132</span>    public boolean getVerticalAxisTrace() {<a name="line.1132"></a>
<span class="sourceLineNo">1133</span>        return this.verticalAxisTrace;<a name="line.1133"></a>
<span class="sourceLineNo">1134</span>    }<a name="line.1134"></a>
<span class="sourceLineNo">1135</span><a name="line.1135"></a>
<span class="sourceLineNo">1136</span>    /**<a name="line.1136"></a>
<span class="sourceLineNo">1137</span>     * A flag that controls trace lines on the vertical axis.<a name="line.1137"></a>
<span class="sourceLineNo">1138</span>     *<a name="line.1138"></a>
<span class="sourceLineNo">1139</span>     * @param flag  &lt;code&gt;true&lt;/code&gt; enables trace lines for the mouse<a name="line.1139"></a>
<span class="sourceLineNo">1140</span>     *              pointer on the vertical axis.<a name="line.1140"></a>
<span class="sourceLineNo">1141</span>     */<a name="line.1141"></a>
<span class="sourceLineNo">1142</span>    public void setVerticalAxisTrace(boolean flag) {<a name="line.1142"></a>
<span class="sourceLineNo">1143</span>        this.verticalAxisTrace = flag;<a name="line.1143"></a>
<span class="sourceLineNo">1144</span>    }<a name="line.1144"></a>
<span class="sourceLineNo">1145</span><a name="line.1145"></a>
<span class="sourceLineNo">1146</span>    /**<a name="line.1146"></a>
<span class="sourceLineNo">1147</span>     * Returns the vertical trace line.<a name="line.1147"></a>
<span class="sourceLineNo">1148</span>     *<a name="line.1148"></a>
<span class="sourceLineNo">1149</span>     * @return The vertical trace line (possibly &lt;code&gt;null&lt;/code&gt;).<a name="line.1149"></a>
<span class="sourceLineNo">1150</span>     */<a name="line.1150"></a>
<span class="sourceLineNo">1151</span>    protected Line2D getVerticalTraceLine() {<a name="line.1151"></a>
<span class="sourceLineNo">1152</span>        return this.verticalTraceLine;<a name="line.1152"></a>
<span class="sourceLineNo">1153</span>    }<a name="line.1153"></a>
<span class="sourceLineNo">1154</span><a name="line.1154"></a>
<span class="sourceLineNo">1155</span>    /**<a name="line.1155"></a>
<span class="sourceLineNo">1156</span>     * Sets the vertical trace line.<a name="line.1156"></a>
<span class="sourceLineNo">1157</span>     *<a name="line.1157"></a>
<span class="sourceLineNo">1158</span>     * @param line  the line (&lt;code&gt;null&lt;/code&gt; permitted).<a name="line.1158"></a>
<span class="sourceLineNo">1159</span>     */<a name="line.1159"></a>
<span class="sourceLineNo">1160</span>    protected void setVerticalTraceLine(Line2D line) {<a name="line.1160"></a>
<span class="sourceLineNo">1161</span>        this.verticalTraceLine = line;<a name="line.1161"></a>
<span class="sourceLineNo">1162</span>    }<a name="line.1162"></a>
<span class="sourceLineNo">1163</span><a name="line.1163"></a>
<span class="sourceLineNo">1164</span>    /**<a name="line.1164"></a>
<span class="sourceLineNo">1165</span>     * Returns the default directory for the "save as" option.<a name="line.1165"></a>
<span class="sourceLineNo">1166</span>     *<a name="line.1166"></a>
<span class="sourceLineNo">1167</span>     * @return The default directory (possibly &lt;code&gt;null&lt;/code&gt;).<a name="line.1167"></a>
<span class="sourceLineNo">1168</span>     *<a name="line.1168"></a>
<span class="sourceLineNo">1169</span>     * @since 1.0.7<a name="line.1169"></a>
<span class="sourceLineNo">1170</span>     */<a name="line.1170"></a>
<span class="sourceLineNo">1171</span>    public File getDefaultDirectoryForSaveAs() {<a name="line.1171"></a>
<span class="sourceLineNo">1172</span>        return this.defaultDirectoryForSaveAs;<a name="line.1172"></a>
<span class="sourceLineNo">1173</span>    }<a name="line.1173"></a>
<span class="sourceLineNo">1174</span><a name="line.1174"></a>
<span class="sourceLineNo">1175</span>    /**<a name="line.1175"></a>
<span class="sourceLineNo">1176</span>     * Sets the default directory for the "save as" option.  If you set this<a name="line.1176"></a>
<span class="sourceLineNo">1177</span>     * to &lt;code&gt;null&lt;/code&gt;, the user's default directory will be used.<a name="line.1177"></a>
<span class="sourceLineNo">1178</span>     *<a name="line.1178"></a>
<span class="sourceLineNo">1179</span>     * @param directory  the directory (&lt;code&gt;null&lt;/code&gt; permitted).<a name="line.1179"></a>
<span class="sourceLineNo">1180</span>     *<a name="line.1180"></a>
<span class="sourceLineNo">1181</span>     * @since 1.0.7<a name="line.1181"></a>
<span class="sourceLineNo">1182</span>     */<a name="line.1182"></a>
<span class="sourceLineNo">1183</span>    public void setDefaultDirectoryForSaveAs(File directory) {<a name="line.1183"></a>
<span class="sourceLineNo">1184</span>        if (directory != null) {<a name="line.1184"></a>
<span class="sourceLineNo">1185</span>            if (!directory.isDirectory()) {<a name="line.1185"></a>
<span class="sourceLineNo">1186</span>                throw new IllegalArgumentException(<a name="line.1186"></a>
<span class="sourceLineNo">1187</span>                        "The 'directory' argument is not a directory.");<a name="line.1187"></a>
<span class="sourceLineNo">1188</span>            }<a name="line.1188"></a>
<span class="sourceLineNo">1189</span>        }<a name="line.1189"></a>
<span class="sourceLineNo">1190</span>        this.defaultDirectoryForSaveAs = directory;<a name="line.1190"></a>
<span class="sourceLineNo">1191</span>    }<a name="line.1191"></a>
<span class="sourceLineNo">1192</span><a name="line.1192"></a>
<span class="sourceLineNo">1193</span>    /**<a name="line.1193"></a>
<span class="sourceLineNo">1194</span>     * Returns &lt;code&gt;true&lt;/code&gt; if file extensions should be enforced, and<a name="line.1194"></a>
<span class="sourceLineNo">1195</span>     * &lt;code&gt;false&lt;/code&gt; otherwise.<a name="line.1195"></a>
<span class="sourceLineNo">1196</span>     *<a name="line.1196"></a>
<span class="sourceLineNo">1197</span>     * @return The flag.<a name="line.1197"></a>
<span class="sourceLineNo">1198</span>     *<a name="line.1198"></a>
<span class="sourceLineNo">1199</span>     * @see #setEnforceFileExtensions(boolean)<a name="line.1199"></a>
<span class="sourceLineNo">1200</span>     */<a name="line.1200"></a>
<span class="sourceLineNo">1201</span>    public boolean isEnforceFileExtensions() {<a name="line.1201"></a>
<span class="sourceLineNo">1202</span>        return this.enforceFileExtensions;<a name="line.1202"></a>
<span class="sourceLineNo">1203</span>    }<a name="line.1203"></a>
<span class="sourceLineNo">1204</span><a name="line.1204"></a>
<span class="sourceLineNo">1205</span>    /**<a name="line.1205"></a>
<span class="sourceLineNo">1206</span>     * Sets a flag that controls whether or not file extensions are enforced.<a name="line.1206"></a>
<span class="sourceLineNo">1207</span>     *<a name="line.1207"></a>
<span class="sourceLineNo">1208</span>     * @param enforce  the new flag value.<a name="line.1208"></a>
<span class="sourceLineNo">1209</span>     *<a name="line.1209"></a>
<span class="sourceLineNo">1210</span>     * @see #isEnforceFileExtensions()<a name="line.1210"></a>
<span class="sourceLineNo">1211</span>     */<a name="line.1211"></a>
<span class="sourceLineNo">1212</span>    public void setEnforceFileExtensions(boolean enforce) {<a name="line.1212"></a>
<span class="sourceLineNo">1213</span>        this.enforceFileExtensions = enforce;<a name="line.1213"></a>
<span class="sourceLineNo">1214</span>    }<a name="line.1214"></a>
<span class="sourceLineNo">1215</span><a name="line.1215"></a>
<span class="sourceLineNo">1216</span>    /**<a name="line.1216"></a>
<span class="sourceLineNo">1217</span>     * Returns the flag that controls whether or not zoom operations are<a name="line.1217"></a>
<span class="sourceLineNo">1218</span>     * centered around the current anchor point.<a name="line.1218"></a>
<span class="sourceLineNo">1219</span>     *<a name="line.1219"></a>
<span class="sourceLineNo">1220</span>     * @return A boolean.<a name="line.1220"></a>
<span class="sourceLineNo">1221</span>     *<a name="line.1221"></a>
<span class="sourceLineNo">1222</span>     * @since 1.0.7<a name="line.1222"></a>
<span class="sourceLineNo">1223</span>     *<a name="line.1223"></a>
<span class="sourceLineNo">1224</span>     * @see #setZoomAroundAnchor(boolean)<a name="line.1224"></a>
<span class="sourceLineNo">1225</span>     */<a name="line.1225"></a>
<span class="sourceLineNo">1226</span>    public boolean getZoomAroundAnchor() {<a name="line.1226"></a>
<span class="sourceLineNo">1227</span>        return this.zoomAroundAnchor;<a name="line.1227"></a>
<span class="sourceLineNo">1228</span>    }<a name="line.1228"></a>
<span class="sourceLineNo">1229</span><a name="line.1229"></a>
<span class="sourceLineNo">1230</span>    /**<a name="line.1230"></a>
<span class="sourceLineNo">1231</span>     * Sets the flag that controls whether or not zoom operations are<a name="line.1231"></a>
<span class="sourceLineNo">1232</span>     * centered around the current anchor point.<a name="line.1232"></a>
<span class="sourceLineNo">1233</span>     *<a name="line.1233"></a>
<span class="sourceLineNo">1234</span>     * @param zoomAroundAnchor  the new flag value.<a name="line.1234"></a>
<span class="sourceLineNo">1235</span>     *<a name="line.1235"></a>
<span class="sourceLineNo">1236</span>     * @since 1.0.7<a name="line.1236"></a>
<span class="sourceLineNo">1237</span>     *<a name="line.1237"></a>
<span class="sourceLineNo">1238</span>     * @see #getZoomAroundAnchor()<a name="line.1238"></a>
<span class="sourceLineNo">1239</span>     */<a name="line.1239"></a>
<span class="sourceLineNo">1240</span>    public void setZoomAroundAnchor(boolean zoomAroundAnchor) {<a name="line.1240"></a>
<span class="sourceLineNo">1241</span>        this.zoomAroundAnchor = zoomAroundAnchor;<a name="line.1241"></a>
<span class="sourceLineNo">1242</span>    }<a name="line.1242"></a>
<span class="sourceLineNo">1243</span><a name="line.1243"></a>
<span class="sourceLineNo">1244</span>    /**<a name="line.1244"></a>
<span class="sourceLineNo">1245</span>     * Returns the zoom rectangle fill paint.<a name="line.1245"></a>
<span class="sourceLineNo">1246</span>     *<a name="line.1246"></a>
<span class="sourceLineNo">1247</span>     * @return The zoom rectangle fill paint (never &lt;code&gt;null&lt;/code&gt;).<a name="line.1247"></a>
<span class="sourceLineNo">1248</span>     *<a name="line.1248"></a>
<span class="sourceLineNo">1249</span>     * @see #setZoomFillPaint(java.awt.Paint)<a name="line.1249"></a>
<span class="sourceLineNo">1250</span>     * @see #setFillZoomRectangle(boolean)<a name="line.1250"></a>
<span class="sourceLineNo">1251</span>     *<a name="line.1251"></a>
<span class="sourceLineNo">1252</span>     * @since 1.0.13<a name="line.1252"></a>
<span class="sourceLineNo">1253</span>     */<a name="line.1253"></a>
<span class="sourceLineNo">1254</span>    public Paint getZoomFillPaint() {<a name="line.1254"></a>
<span class="sourceLineNo">1255</span>        return this.zoomFillPaint;<a name="line.1255"></a>
<span class="sourceLineNo">1256</span>    }<a name="line.1256"></a>
<span class="sourceLineNo">1257</span><a name="line.1257"></a>
<span class="sourceLineNo">1258</span>    /**<a name="line.1258"></a>
<span class="sourceLineNo">1259</span>     * Sets the zoom rectangle fill paint.<a name="line.1259"></a>
<span class="sourceLineNo">1260</span>     *<a name="line.1260"></a>
<span class="sourceLineNo">1261</span>     * @param paint  the paint (&lt;code&gt;null&lt;/code&gt; not permitted).<a name="line.1261"></a>
<span class="sourceLineNo">1262</span>     *<a name="line.1262"></a>
<span class="sourceLineNo">1263</span>     * @see #getZoomFillPaint()<a name="line.1263"></a>
<span class="sourceLineNo">1264</span>     * @see #getFillZoomRectangle()<a name="line.1264"></a>
<span class="sourceLineNo">1265</span>     *<a name="line.1265"></a>
<span class="sourceLineNo">1266</span>     * @since 1.0.13<a name="line.1266"></a>
<span class="sourceLineNo">1267</span>     */<a name="line.1267"></a>
<span class="sourceLineNo">1268</span>    public void setZoomFillPaint(Paint paint) {<a name="line.1268"></a>
<span class="sourceLineNo">1269</span>        if (paint == null) {<a name="line.1269"></a>
<span class="sourceLineNo">1270</span>            throw new IllegalArgumentException("Null 'paint' argument.");<a name="line.1270"></a>
<span class="sourceLineNo">1271</span>        }<a name="line.1271"></a>
<span class="sourceLineNo">1272</span>        this.zoomFillPaint = paint;<a name="line.1272"></a>
<span class="sourceLineNo">1273</span>    }<a name="line.1273"></a>
<span class="sourceLineNo">1274</span><a name="line.1274"></a>
<span class="sourceLineNo">1275</span>    /**<a name="line.1275"></a>
<span class="sourceLineNo">1276</span>     * Returns the zoom rectangle outline paint.<a name="line.1276"></a>
<span class="sourceLineNo">1277</span>     *<a name="line.1277"></a>
<span class="sourceLineNo">1278</span>     * @return The zoom rectangle outline paint (never &lt;code&gt;null&lt;/code&gt;).<a name="line.1278"></a>
<span class="sourceLineNo">1279</span>     *<a name="line.1279"></a>
<span class="sourceLineNo">1280</span>     * @see #setZoomOutlinePaint(java.awt.Paint)<a name="line.1280"></a>
<span class="sourceLineNo">1281</span>     * @see #setFillZoomRectangle(boolean)<a name="line.1281"></a>
<span class="sourceLineNo">1282</span>     *<a name="line.1282"></a>
<span class="sourceLineNo">1283</span>     * @since 1.0.13<a name="line.1283"></a>
<span class="sourceLineNo">1284</span>     */<a name="line.1284"></a>
<span class="sourceLineNo">1285</span>    public Paint getZoomOutlinePaint() {<a name="line.1285"></a>
<span class="sourceLineNo">1286</span>        return this.zoomOutlinePaint;<a name="line.1286"></a>
<span class="sourceLineNo">1287</span>    }<a name="line.1287"></a>
<span class="sourceLineNo">1288</span><a name="line.1288"></a>
<span class="sourceLineNo">1289</span>    /**<a name="line.1289"></a>
<span class="sourceLineNo">1290</span>     * Sets the zoom rectangle outline paint.<a name="line.1290"></a>
<span class="sourceLineNo">1291</span>     *<a name="line.1291"></a>
<span class="sourceLineNo">1292</span>     * @param paint  the paint (&lt;code&gt;null&lt;/code&gt; not permitted).<a name="line.1292"></a>
<span class="sourceLineNo">1293</span>     *<a name="line.1293"></a>
<span class="sourceLineNo">1294</span>     * @see #getZoomOutlinePaint()<a name="line.1294"></a>
<span class="sourceLineNo">1295</span>     * @see #getFillZoomRectangle()<a name="line.1295"></a>
<span class="sourceLineNo">1296</span>     *<a name="line.1296"></a>
<span class="sourceLineNo">1297</span>     * @since 1.0.13<a name="line.1297"></a>
<span class="sourceLineNo">1298</span>     */<a name="line.1298"></a>
<span class="sourceLineNo">1299</span>    public void setZoomOutlinePaint(Paint paint) {<a name="line.1299"></a>
<span class="sourceLineNo">1300</span>        this.zoomOutlinePaint = paint;<a name="line.1300"></a>
<span class="sourceLineNo">1301</span>    }<a name="line.1301"></a>
<span class="sourceLineNo">1302</span><a name="line.1302"></a>
<span class="sourceLineNo">1303</span>    /**<a name="line.1303"></a>
<span class="sourceLineNo">1304</span>     * The mouse wheel handler.  This will be an instance of MouseWheelHandler<a name="line.1304"></a>
<span class="sourceLineNo">1305</span>     * but we can't reference that class directly because it depends on JRE 1.4<a name="line.1305"></a>
<span class="sourceLineNo">1306</span>     * and we still want to support JRE 1.3.1.<a name="line.1306"></a>
<span class="sourceLineNo">1307</span>     */<a name="line.1307"></a>
<span class="sourceLineNo">1308</span>    private Object mouseWheelHandler;<a name="line.1308"></a>
<span class="sourceLineNo">1309</span><a name="line.1309"></a>
<span class="sourceLineNo">1310</span>    /**<a name="line.1310"></a>
<span class="sourceLineNo">1311</span>     * Returns &lt;code&gt;true&lt;/code&gt; if the mouse wheel handler is enabled, and<a name="line.1311"></a>
<span class="sourceLineNo">1312</span>     * &lt;code&gt;false&lt;/code&gt; otherwise.<a name="line.1312"></a>
<span class="sourceLineNo">1313</span>     *<a name="line.1313"></a>
<span class="sourceLineNo">1314</span>     * @return A boolean.<a name="line.1314"></a>
<span class="sourceLineNo">1315</span>     *<a name="line.1315"></a>
<span class="sourceLineNo">1316</span>     * @since 1.0.13<a name="line.1316"></a>
<span class="sourceLineNo">1317</span>     */<a name="line.1317"></a>
<span class="sourceLineNo">1318</span>    public boolean isMouseWheelEnabled() {<a name="line.1318"></a>
<span class="sourceLineNo">1319</span>        return this.mouseWheelHandler != null;<a name="line.1319"></a>
<span class="sourceLineNo">1320</span>    }<a name="line.1320"></a>
<span class="sourceLineNo">1321</span><a name="line.1321"></a>
<span class="sourceLineNo">1322</span>    /**<a name="line.1322"></a>
<span class="sourceLineNo">1323</span>     * Enables or disables mouse wheel support for the panel.<a name="line.1323"></a>
<span class="sourceLineNo">1324</span>     * Note that this method does nothing when running JFreeChart on JRE 1.3.1,<a name="line.1324"></a>
<span class="sourceLineNo">1325</span>     * because that older version of the Java runtime does not support<a name="line.1325"></a>
<span class="sourceLineNo">1326</span>     * mouse wheel events.<a name="line.1326"></a>
<span class="sourceLineNo">1327</span>     *<a name="line.1327"></a>
<span class="sourceLineNo">1328</span>     * @param flag  a boolean.<a name="line.1328"></a>
<span class="sourceLineNo">1329</span>     *<a name="line.1329"></a>
<span class="sourceLineNo">1330</span>     * @since 1.0.13<a name="line.1330"></a>
<span class="sourceLineNo">1331</span>     */<a name="line.1331"></a>
<span class="sourceLineNo">1332</span>    public void setMouseWheelEnabled(boolean flag) {<a name="line.1332"></a>
<span class="sourceLineNo">1333</span>        if (flag &amp;&amp; this.mouseWheelHandler == null) {<a name="line.1333"></a>
<span class="sourceLineNo">1334</span>            // use reflection to instantiate a mouseWheelHandler because to<a name="line.1334"></a>
<span class="sourceLineNo">1335</span>            // continue supporting JRE 1.3.1 we cannot depend on the<a name="line.1335"></a>
<span class="sourceLineNo">1336</span>            // MouseWheelListener interface directly<a name="line.1336"></a>
<span class="sourceLineNo">1337</span>            try {<a name="line.1337"></a>
<span class="sourceLineNo">1338</span>                Class c = Class.forName("org.jfree.chart.MouseWheelHandler");<a name="line.1338"></a>
<span class="sourceLineNo">1339</span>                Constructor cc = c.getConstructor(new Class[] {<a name="line.1339"></a>
<span class="sourceLineNo">1340</span>                        ChartPanel.class});<a name="line.1340"></a>
<span class="sourceLineNo">1341</span>                Object mwh = cc.newInstance(new Object[] {this});<a name="line.1341"></a>
<span class="sourceLineNo">1342</span>                this.mouseWheelHandler = mwh;<a name="line.1342"></a>
<span class="sourceLineNo">1343</span>            }<a name="line.1343"></a>
<span class="sourceLineNo">1344</span>            catch (ClassNotFoundException e) {<a name="line.1344"></a>
<span class="sourceLineNo">1345</span>                // the class isn't there, so we must have compiled JFreeChart<a name="line.1345"></a>
<span class="sourceLineNo">1346</span>                // with JDK 1.3.1 - thus, we can't have mouse wheel support<a name="line.1346"></a>
<span class="sourceLineNo">1347</span>            }<a name="line.1347"></a>
<span class="sourceLineNo">1348</span>            catch (SecurityException e) {<a name="line.1348"></a>
<span class="sourceLineNo">1349</span>                e.printStackTrace();<a name="line.1349"></a>
<span class="sourceLineNo">1350</span>            }<a name="line.1350"></a>
<span class="sourceLineNo">1351</span>            catch (NoSuchMethodException e) {<a name="line.1351"></a>
<span class="sourceLineNo">1352</span>                e.printStackTrace();<a name="line.1352"></a>
<span class="sourceLineNo">1353</span>            }<a name="line.1353"></a>
<span class="sourceLineNo">1354</span>            catch (IllegalArgumentException e) {<a name="line.1354"></a>
<span class="sourceLineNo">1355</span>                e.printStackTrace();<a name="line.1355"></a>
<span class="sourceLineNo">1356</span>            }<a name="line.1356"></a>
<span class="sourceLineNo">1357</span>            catch (InstantiationException e) {<a name="line.1357"></a>
<span class="sourceLineNo">1358</span>                e.printStackTrace();<a name="line.1358"></a>
<span class="sourceLineNo">1359</span>            }<a name="line.1359"></a>
<span class="sourceLineNo">1360</span>            catch (IllegalAccessException e) {<a name="line.1360"></a>
<span class="sourceLineNo">1361</span>                e.printStackTrace();<a name="line.1361"></a>
<span class="sourceLineNo">1362</span>            }<a name="line.1362"></a>
<span class="sourceLineNo">1363</span>            catch (InvocationTargetException e) {<a name="line.1363"></a>
<span class="sourceLineNo">1364</span>                e.printStackTrace();<a name="line.1364"></a>
<span class="sourceLineNo">1365</span>            }<a name="line.1365"></a>
<span class="sourceLineNo">1366</span>        }<a name="line.1366"></a>
<span class="sourceLineNo">1367</span>        else if (!flag &amp;&amp; this.mouseWheelHandler != null) {<a name="line.1367"></a>
<span class="sourceLineNo">1368</span>            // use reflection to deregister the mouseWheelHandler<a name="line.1368"></a>
<span class="sourceLineNo">1369</span>            try {<a name="line.1369"></a>
<span class="sourceLineNo">1370</span>                Class mwl = Class.forName("java.awt.event.MouseWheelListener");<a name="line.1370"></a>
<span class="sourceLineNo">1371</span>                Class c2 = ChartPanel.class;<a name="line.1371"></a>
<span class="sourceLineNo">1372</span>                Method m = c2.getMethod("removeMouseWheelListener",<a name="line.1372"></a>
<span class="sourceLineNo">1373</span>                        new Class[] {mwl});<a name="line.1373"></a>
<span class="sourceLineNo">1374</span>                m.invoke(this, new Object[] {this.mouseWheelHandler});<a name="line.1374"></a>
<span class="sourceLineNo">1375</span>                this.mouseWheelHandler = null;<a name="line.1375"></a>
<span class="sourceLineNo">1376</span>            }<a name="line.1376"></a>
<span class="sourceLineNo">1377</span>            catch (ClassNotFoundException e) {<a name="line.1377"></a>
<span class="sourceLineNo">1378</span>                // must be running on JRE 1.3.1, so just ignore this<a name="line.1378"></a>
<span class="sourceLineNo">1379</span>            }<a name="line.1379"></a>
<span class="sourceLineNo">1380</span>            catch (SecurityException e) {<a name="line.1380"></a>
<span class="sourceLineNo">1381</span>                e.printStackTrace();<a name="line.1381"></a>
<span class="sourceLineNo">1382</span>            }<a name="line.1382"></a>
<span class="sourceLineNo">1383</span>            catch (NoSuchMethodException e) {<a name="line.1383"></a>
<span class="sourceLineNo">1384</span>                e.printStackTrace();<a name="line.1384"></a>
<span class="sourceLineNo">1385</span>            }<a name="line.1385"></a>
<span class="sourceLineNo">1386</span>            catch (IllegalArgumentException e) {<a name="line.1386"></a>
<span class="sourceLineNo">1387</span>                e.printStackTrace();<a name="line.1387"></a>
<span class="sourceLineNo">1388</span>            }<a name="line.1388"></a>
<span class="sourceLineNo">1389</span>            catch (IllegalAccessException e) {<a name="line.1389"></a>
<span class="sourceLineNo">1390</span>                e.printStackTrace();<a name="line.1390"></a>
<span class="sourceLineNo">1391</span>            }<a name="line.1391"></a>
<span class="sourceLineNo">1392</span>            catch (InvocationTargetException e) {<a name="line.1392"></a>
<span class="sourceLineNo">1393</span>                e.printStackTrace();<a name="line.1393"></a>
<span class="sourceLineNo">1394</span>            }<a name="line.1394"></a>
<span class="sourceLineNo">1395</span>        }<a name="line.1395"></a>
<span class="sourceLineNo">1396</span>    }<a name="line.1396"></a>
<span class="sourceLineNo">1397</span><a name="line.1397"></a>
<span class="sourceLineNo">1398</span>    /**<a name="line.1398"></a>
<span class="sourceLineNo">1399</span>     * Add an overlay to the panel.<a name="line.1399"></a>
<span class="sourceLineNo">1400</span>     *<a name="line.1400"></a>
<span class="sourceLineNo">1401</span>     * @param overlay  the overlay (&lt;code&gt;null&lt;/code&gt; not permitted).<a name="line.1401"></a>
<span class="sourceLineNo">1402</span>     *<a name="line.1402"></a>
<span class="sourceLineNo">1403</span>     * @since 1.0.13<a name="line.1403"></a>
<span class="sourceLineNo">1404</span>     */<a name="line.1404"></a>
<span class="sourceLineNo">1405</span>    public void addOverlay(Overlay overlay) {<a name="line.1405"></a>
<span class="sourceLineNo">1406</span>        if (overlay == null) {<a name="line.1406"></a>
<span class="sourceLineNo">1407</span>            throw new IllegalArgumentException("Null 'overlay' argument.");<a name="line.1407"></a>
<span class="sourceLineNo">1408</span>        }<a name="line.1408"></a>
<span class="sourceLineNo">1409</span>        this.overlays.add(overlay);<a name="line.1409"></a>
<span class="sourceLineNo">1410</span>        overlay.addChangeListener(this);<a name="line.1410"></a>
<span class="sourceLineNo">1411</span>        repaint();<a name="line.1411"></a>
<span class="sourceLineNo">1412</span>    }<a name="line.1412"></a>
<span class="sourceLineNo">1413</span><a name="line.1413"></a>
<span class="sourceLineNo">1414</span>    /**<a name="line.1414"></a>
<span class="sourceLineNo">1415</span>     * Removes an overlay from the panel.<a name="line.1415"></a>
<span class="sourceLineNo">1416</span>     *<a name="line.1416"></a>
<span class="sourceLineNo">1417</span>     * @param overlay  the overlay to remove (&lt;code&gt;null&lt;/code&gt; not permitted).<a name="line.1417"></a>
<span class="sourceLineNo">1418</span>     *<a name="line.1418"></a>
<span class="sourceLineNo">1419</span>     * @since 1.0.13<a name="line.1419"></a>
<span class="sourceLineNo">1420</span>     */<a name="line.1420"></a>
<span class="sourceLineNo">1421</span>    public void removeOverlay(Overlay overlay) {<a name="line.1421"></a>
<span class="sourceLineNo">1422</span>        if (overlay == null) {<a name="line.1422"></a>
<span class="sourceLineNo">1423</span>            throw new IllegalArgumentException("Null 'overlay' argument.");<a name="line.1423"></a>
<span class="sourceLineNo">1424</span>        }<a name="line.1424"></a>
<span class="sourceLineNo">1425</span>        boolean removed = this.overlays.remove(overlay);<a name="line.1425"></a>
<span class="sourceLineNo">1426</span>        if (removed) {<a name="line.1426"></a>
<span class="sourceLineNo">1427</span>            overlay.removeChangeListener(this);<a name="line.1427"></a>
<span class="sourceLineNo">1428</span>            repaint();<a name="line.1428"></a>
<span class="sourceLineNo">1429</span>        }<a name="line.1429"></a>
<span class="sourceLineNo">1430</span>    }<a name="line.1430"></a>
<span class="sourceLineNo">1431</span><a name="line.1431"></a>
<span class="sourceLineNo">1432</span>    /**<a name="line.1432"></a>
<span class="sourceLineNo">1433</span>     * Handles a change to an overlay by repainting the panel.<a name="line.1433"></a>
<span class="sourceLineNo">1434</span>     *<a name="line.1434"></a>
<span class="sourceLineNo">1435</span>     * @param event  the event.<a name="line.1435"></a>
<span class="sourceLineNo">1436</span>     *<a name="line.1436"></a>
<span class="sourceLineNo">1437</span>     * @since 1.0.13<a name="line.1437"></a>
<span class="sourceLineNo">1438</span>     */<a name="line.1438"></a>
<span class="sourceLineNo">1439</span>    public void overlayChanged(OverlayChangeEvent event) {<a name="line.1439"></a>
<span class="sourceLineNo">1440</span>        repaint();<a name="line.1440"></a>
<span class="sourceLineNo">1441</span>    }<a name="line.1441"></a>
<span class="sourceLineNo">1442</span><a name="line.1442"></a>
<span class="sourceLineNo">1443</span>    /**<a name="line.1443"></a>
<span class="sourceLineNo">1444</span>     * Switches the display of tooltips for the panel on or off.  Note that<a name="line.1444"></a>
<span class="sourceLineNo">1445</span>     * tooltips can only be displayed if the chart has been configured to<a name="line.1445"></a>
<span class="sourceLineNo">1446</span>     * generate tooltip items.<a name="line.1446"></a>
<span class="sourceLineNo">1447</span>     *<a name="line.1447"></a>
<span class="sourceLineNo">1448</span>     * @param flag  &lt;code&gt;true&lt;/code&gt; to enable tooltips, &lt;code&gt;false&lt;/code&gt; to<a name="line.1448"></a>
<span class="sourceLineNo">1449</span>     *              disable tooltips.<a name="line.1449"></a>
<span class="sourceLineNo">1450</span>     */<a name="line.1450"></a>
<span class="sourceLineNo">1451</span>    public void setDisplayToolTips(boolean flag) {<a name="line.1451"></a>
<span class="sourceLineNo">1452</span>        if (flag) {<a name="line.1452"></a>
<span class="sourceLineNo">1453</span>            ToolTipManager.sharedInstance().registerComponent(this);<a name="line.1453"></a>
<span class="sourceLineNo">1454</span>        }<a name="line.1454"></a>
<span class="sourceLineNo">1455</span>        else {<a name="line.1455"></a>
<span class="sourceLineNo">1456</span>            ToolTipManager.sharedInstance().unregisterComponent(this);<a name="line.1456"></a>
<span class="sourceLineNo">1457</span>        }<a name="line.1457"></a>
<span class="sourceLineNo">1458</span>    }<a name="line.1458"></a>
<span class="sourceLineNo">1459</span><a name="line.1459"></a>
<span class="sourceLineNo">1460</span>    /**<a name="line.1460"></a>
<span class="sourceLineNo">1461</span>     * Returns a string for the tooltip.<a name="line.1461"></a>
<span class="sourceLineNo">1462</span>     *<a name="line.1462"></a>
<span class="sourceLineNo">1463</span>     * @param e  the mouse event.<a name="line.1463"></a>
<span class="sourceLineNo">1464</span>     *<a name="line.1464"></a>
<span class="sourceLineNo">1465</span>     * @return A tool tip or &lt;code&gt;null&lt;/code&gt; if no tooltip is available.<a name="line.1465"></a>
<span class="sourceLineNo">1466</span>     */<a name="line.1466"></a>
<span class="sourceLineNo">1467</span>    public String getToolTipText(MouseEvent e) {<a name="line.1467"></a>
<span class="sourceLineNo">1468</span><a name="line.1468"></a>
<span class="sourceLineNo">1469</span>        String result = null;<a name="line.1469"></a>
<span class="sourceLineNo">1470</span>        if (this.info != null) {<a name="line.1470"></a>
<span class="sourceLineNo">1471</span>            EntityCollection entities = this.info.getEntityCollection();<a name="line.1471"></a>
<span class="sourceLineNo">1472</span>            if (entities != null) {<a name="line.1472"></a>
<span class="sourceLineNo">1473</span>                Insets insets = getInsets();<a name="line.1473"></a>
<span class="sourceLineNo">1474</span>                ChartEntity entity = entities.getEntity(<a name="line.1474"></a>
<span class="sourceLineNo">1475</span>                        (int) ((e.getX() - insets.left) / this.scaleX),<a name="line.1475"></a>
<span class="sourceLineNo">1476</span>                        (int) ((e.getY() - insets.top) / this.scaleY));<a name="line.1476"></a>
<span class="sourceLineNo">1477</span>                if (entity != null) {<a name="line.1477"></a>
<span class="sourceLineNo">1478</span>                    result = entity.getToolTipText();<a name="line.1478"></a>
<span class="sourceLineNo">1479</span>                }<a name="line.1479"></a>
<span class="sourceLineNo">1480</span>            }<a name="line.1480"></a>
<span class="sourceLineNo">1481</span>        }<a name="line.1481"></a>
<span class="sourceLineNo">1482</span>        return result;<a name="line.1482"></a>
<span class="sourceLineNo">1483</span><a name="line.1483"></a>
<span class="sourceLineNo">1484</span>    }<a name="line.1484"></a>
<span class="sourceLineNo">1485</span><a name="line.1485"></a>
<span class="sourceLineNo">1486</span>    /**<a name="line.1486"></a>
<span class="sourceLineNo">1487</span>     * Translates a Java2D point on the chart to a screen location.<a name="line.1487"></a>
<span class="sourceLineNo">1488</span>     *<a name="line.1488"></a>
<span class="sourceLineNo">1489</span>     * @param java2DPoint  the Java2D point.<a name="line.1489"></a>
<span class="sourceLineNo">1490</span>     *<a name="line.1490"></a>
<span class="sourceLineNo">1491</span>     * @return The screen location.<a name="line.1491"></a>
<span class="sourceLineNo">1492</span>     */<a name="line.1492"></a>
<span class="sourceLineNo">1493</span>    public Point translateJava2DToScreen(Point2D java2DPoint) {<a name="line.1493"></a>
<span class="sourceLineNo">1494</span>        Insets insets = getInsets();<a name="line.1494"></a>
<span class="sourceLineNo">1495</span>        int x = (int) (java2DPoint.getX() * this.scaleX + insets.left);<a name="line.1495"></a>
<span class="sourceLineNo">1496</span>        int y = (int) (java2DPoint.getY() * this.scaleY + insets.top);<a name="line.1496"></a>
<span class="sourceLineNo">1497</span>        return new Point(x, y);<a name="line.1497"></a>
<span class="sourceLineNo">1498</span>    }<a name="line.1498"></a>
<span class="sourceLineNo">1499</span><a name="line.1499"></a>
<span class="sourceLineNo">1500</span>    /**<a name="line.1500"></a>
<span class="sourceLineNo">1501</span>     * Translates a panel (component) location to a Java2D point.<a name="line.1501"></a>
<span class="sourceLineNo">1502</span>     *<a name="line.1502"></a>
<span class="sourceLineNo">1503</span>     * @param screenPoint  the screen location (&lt;code&gt;null&lt;/code&gt; not<a name="line.1503"></a>
<span class="sourceLineNo">1504</span>     *                     permitted).<a name="line.1504"></a>
<span class="sourceLineNo">1505</span>     *<a name="line.1505"></a>
<span class="sourceLineNo">1506</span>     * @return The Java2D coordinates.<a name="line.1506"></a>
<span class="sourceLineNo">1507</span>     */<a name="line.1507"></a>
<span class="sourceLineNo">1508</span>    public Point2D translateScreenToJava2D(Point screenPoint) {<a name="line.1508"></a>
<span class="sourceLineNo">1509</span>        Insets insets = getInsets();<a name="line.1509"></a>
<span class="sourceLineNo">1510</span>        double x = (screenPoint.getX() - insets.left) / this.scaleX;<a name="line.1510"></a>
<span class="sourceLineNo">1511</span>        double y = (screenPoint.getY() - insets.top) / this.scaleY;<a name="line.1511"></a>
<span class="sourceLineNo">1512</span>        return new Point2D.Double(x, y);<a name="line.1512"></a>
<span class="sourceLineNo">1513</span>    }<a name="line.1513"></a>
<span class="sourceLineNo">1514</span><a name="line.1514"></a>
<span class="sourceLineNo">1515</span>    /**<a name="line.1515"></a>
<span class="sourceLineNo">1516</span>     * Applies any scaling that is in effect for the chart drawing to the<a name="line.1516"></a>
<span class="sourceLineNo">1517</span>     * given rectangle.<a name="line.1517"></a>
<span class="sourceLineNo">1518</span>     *<a name="line.1518"></a>
<span class="sourceLineNo">1519</span>     * @param rect  the rectangle (&lt;code&gt;null&lt;/code&gt; not permitted).<a name="line.1519"></a>
<span class="sourceLineNo">1520</span>     *<a name="line.1520"></a>
<span class="sourceLineNo">1521</span>     * @return A new scaled rectangle.<a name="line.1521"></a>
<span class="sourceLineNo">1522</span>     */<a name="line.1522"></a>
<span class="sourceLineNo">1523</span>    public Rectangle2D scale(Rectangle2D rect) {<a name="line.1523"></a>
<span class="sourceLineNo">1524</span>        Insets insets = getInsets();<a name="line.1524"></a>
<span class="sourceLineNo">1525</span>        double x = rect.getX() * getScaleX() + insets.left;<a name="line.1525"></a>
<span class="sourceLineNo">1526</span>        double y = rect.getY() * getScaleY() + insets.top;<a name="line.1526"></a>
<span class="sourceLineNo">1527</span>        double w = rect.getWidth() * getScaleX();<a name="line.1527"></a>
<span class="sourceLineNo">1528</span>        double h = rect.getHeight() * getScaleY();<a name="line.1528"></a>
<span class="sourceLineNo">1529</span>        return new Rectangle2D.Double(x, y, w, h);<a name="line.1529"></a>
<span class="sourceLineNo">1530</span>    }<a name="line.1530"></a>
<span class="sourceLineNo">1531</span><a name="line.1531"></a>
<span class="sourceLineNo">1532</span>    /**<a name="line.1532"></a>
<span class="sourceLineNo">1533</span>     * Returns the chart entity at a given point.<a name="line.1533"></a>
<span class="sourceLineNo">1534</span>     * &lt;P&gt;<a name="line.1534"></a>
<span class="sourceLineNo">1535</span>     * This method will return null if there is (a) no entity at the given<a name="line.1535"></a>
<span class="sourceLineNo">1536</span>     * point, or (b) no entity collection has been generated.<a name="line.1536"></a>
<span class="sourceLineNo">1537</span>     *<a name="line.1537"></a>
<span class="sourceLineNo">1538</span>     * @param viewX  the x-coordinate.<a name="line.1538"></a>
<span class="sourceLineNo">1539</span>     * @param viewY  the y-coordinate.<a name="line.1539"></a>
<span class="sourceLineNo">1540</span>     *<a name="line.1540"></a>
<span class="sourceLineNo">1541</span>     * @return The chart entity (possibly &lt;code&gt;null&lt;/code&gt;).<a name="line.1541"></a>
<span class="sourceLineNo">1542</span>     */<a name="line.1542"></a>
<span class="sourceLineNo">1543</span>    public ChartEntity getEntityForPoint(int viewX, int viewY) {<a name="line.1543"></a>
<span class="sourceLineNo">1544</span><a name="line.1544"></a>
<span class="sourceLineNo">1545</span>        ChartEntity result = null;<a name="line.1545"></a>
<span class="sourceLineNo">1546</span>        if (this.info != null) {<a name="line.1546"></a>
<span class="sourceLineNo">1547</span>            Insets insets = getInsets();<a name="line.1547"></a>
<span class="sourceLineNo">1548</span>            double x = (viewX - insets.left) / this.scaleX;<a name="line.1548"></a>
<span class="sourceLineNo">1549</span>            double y = (viewY - insets.top) / this.scaleY;<a name="line.1549"></a>
<span class="sourceLineNo">1550</span>            EntityCollection entities = this.info.getEntityCollection();<a name="line.1550"></a>
<span class="sourceLineNo">1551</span>            result = entities != null ? entities.getEntity(x, y) : null;<a name="line.1551"></a>
<span class="sourceLineNo">1552</span>        }<a name="line.1552"></a>
<span class="sourceLineNo">1553</span>        return result;<a name="line.1553"></a>
<span class="sourceLineNo">1554</span><a name="line.1554"></a>
<span class="sourceLineNo">1555</span>    }<a name="line.1555"></a>
<span class="sourceLineNo">1556</span><a name="line.1556"></a>
<span class="sourceLineNo">1557</span>    /**<a name="line.1557"></a>
<span class="sourceLineNo">1558</span>     * Returns the flag that controls whether or not the offscreen buffer<a name="line.1558"></a>
<span class="sourceLineNo">1559</span>     * needs to be refreshed.<a name="line.1559"></a>
<span class="sourceLineNo">1560</span>     *<a name="line.1560"></a>
<span class="sourceLineNo">1561</span>     * @return A boolean.<a name="line.1561"></a>
<span class="sourceLineNo">1562</span>     */<a name="line.1562"></a>
<span class="sourceLineNo">1563</span>    public boolean getRefreshBuffer() {<a name="line.1563"></a>
<span class="sourceLineNo">1564</span>        return this.refreshBuffer;<a name="line.1564"></a>
<span class="sourceLineNo">1565</span>    }<a name="line.1565"></a>
<span class="sourceLineNo">1566</span><a name="line.1566"></a>
<span class="sourceLineNo">1567</span>    /**<a name="line.1567"></a>
<span class="sourceLineNo">1568</span>     * Sets the refresh buffer flag.  This flag is used to avoid unnecessary<a name="line.1568"></a>
<span class="sourceLineNo">1569</span>     * redrawing of the chart when the offscreen image buffer is used.<a name="line.1569"></a>
<span class="sourceLineNo">1570</span>     *<a name="line.1570"></a>
<span class="sourceLineNo">1571</span>     * @param flag  &lt;code&gt;true&lt;/code&gt; indicates that the buffer should be<a name="line.1571"></a>
<span class="sourceLineNo">1572</span>     *              refreshed.<a name="line.1572"></a>
<span class="sourceLineNo">1573</span>     */<a name="line.1573"></a>
<span class="sourceLineNo">1574</span>    public void setRefreshBuffer(boolean flag) {<a name="line.1574"></a>
<span class="sourceLineNo">1575</span>        this.refreshBuffer = flag;<a name="line.1575"></a>
<span class="sourceLineNo">1576</span>    }<a name="line.1576"></a>
<span class="sourceLineNo">1577</span><a name="line.1577"></a>
<span class="sourceLineNo">1578</span>    /**<a name="line.1578"></a>
<span class="sourceLineNo">1579</span>     * Paints the component by drawing the chart to fill the entire component,<a name="line.1579"></a>
<span class="sourceLineNo">1580</span>     * but allowing for the insets (which will be non-zero if a border has been<a name="line.1580"></a>
<span class="sourceLineNo">1581</span>     * set for this component).  To increase performance (at the expense of<a name="line.1581"></a>
<span class="sourceLineNo">1582</span>     * memory), an off-screen buffer image can be used.<a name="line.1582"></a>
<span class="sourceLineNo">1583</span>     *<a name="line.1583"></a>
<span class="sourceLineNo">1584</span>     * @param g  the graphics device for drawing on.<a name="line.1584"></a>
<span class="sourceLineNo">1585</span>     */<a name="line.1585"></a>
<span class="sourceLineNo">1586</span>    public void paintComponent(Graphics g) {<a name="line.1586"></a>
<span class="sourceLineNo">1587</span>        super.paintComponent(g);<a name="line.1587"></a>
<span class="sourceLineNo">1588</span>        if (this.chart == null) {<a name="line.1588"></a>
<span class="sourceLineNo">1589</span>            return;<a name="line.1589"></a>
<span class="sourceLineNo">1590</span>        }<a name="line.1590"></a>
<span class="sourceLineNo">1591</span>        Graphics2D g2 = (Graphics2D) g.create();<a name="line.1591"></a>
<span class="sourceLineNo">1592</span><a name="line.1592"></a>
<span class="sourceLineNo">1593</span>        // first determine the size of the chart rendering area...<a name="line.1593"></a>
<span class="sourceLineNo">1594</span>        Dimension size = getSize();<a name="line.1594"></a>
<span class="sourceLineNo">1595</span>        Insets insets = getInsets();<a name="line.1595"></a>
<span class="sourceLineNo">1596</span>        Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top,<a name="line.1596"></a>
<span class="sourceLineNo">1597</span>                size.getWidth() - insets.left - insets.right,<a name="line.1597"></a>
<span class="sourceLineNo">1598</span>                size.getHeight() - insets.top - insets.bottom);<a name="line.1598"></a>
<span class="sourceLineNo">1599</span><a name="line.1599"></a>
<span class="sourceLineNo">1600</span>        // work out if scaling is required...<a name="line.1600"></a>
<span class="sourceLineNo">1601</span>        boolean scale = false;<a name="line.1601"></a>
<span class="sourceLineNo">1602</span>        double drawWidth = available.getWidth();<a name="line.1602"></a>
<span class="sourceLineNo">1603</span>        double drawHeight = available.getHeight();<a name="line.1603"></a>
<span class="sourceLineNo">1604</span>        this.scaleX = 1.0;<a name="line.1604"></a>
<span class="sourceLineNo">1605</span>        this.scaleY = 1.0;<a name="line.1605"></a>
<span class="sourceLineNo">1606</span><a name="line.1606"></a>
<span class="sourceLineNo">1607</span>        if (drawWidth &lt; this.minimumDrawWidth) {<a name="line.1607"></a>
<span class="sourceLineNo">1608</span>            this.scaleX = drawWidth / this.minimumDrawWidth;<a name="line.1608"></a>
<span class="sourceLineNo">1609</span>            drawWidth = this.minimumDrawWidth;<a name="line.1609"></a>
<span class="sourceLineNo">1610</span>            scale = true;<a name="line.1610"></a>
<span class="sourceLineNo">1611</span>        }<a name="line.1611"></a>
<span class="sourceLineNo">1612</span>        else if (drawWidth &gt; this.maximumDrawWidth) {<a name="line.1612"></a>
<span class="sourceLineNo">1613</span>            this.scaleX = drawWidth / this.maximumDrawWidth;<a name="line.1613"></a>
<span class="sourceLineNo">1614</span>            drawWidth = this.maximumDrawWidth;<a name="line.1614"></a>
<span class="sourceLineNo">1615</span>            scale = true;<a name="line.1615"></a>
<span class="sourceLineNo">1616</span>        }<a name="line.1616"></a>
<span class="sourceLineNo">1617</span><a name="line.1617"></a>
<span class="sourceLineNo">1618</span>        if (drawHeight &lt; this.minimumDrawHeight) {<a name="line.1618"></a>
<span class="sourceLineNo">1619</span>            this.scaleY = drawHeight / this.minimumDrawHeight;<a name="line.1619"></a>
<span class="sourceLineNo">1620</span>            drawHeight = this.minimumDrawHeight;<a name="line.1620"></a>
<span class="sourceLineNo">1621</span>            scale = true;<a name="line.1621"></a>
<span class="sourceLineNo">1622</span>        }<a name="line.1622"></a>
<span class="sourceLineNo">1623</span>        else if (drawHeight &gt; this.maximumDrawHeight) {<a name="line.1623"></a>
<span class="sourceLineNo">1624</span>            this.scaleY = drawHeight / this.maximumDrawHeight;<a name="line.1624"></a>
<span class="sourceLineNo">1625</span>            drawHeight = this.maximumDrawHeight;<a name="line.1625"></a>
<span class="sourceLineNo">1626</span>            scale = true;<a name="line.1626"></a>
<span class="sourceLineNo">1627</span>        }<a name="line.1627"></a>
<span class="sourceLineNo">1628</span><a name="line.1628"></a>
<span class="sourceLineNo">1629</span>        Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth,<a name="line.1629"></a>
<span class="sourceLineNo">1630</span>                drawHeight);<a name="line.1630"></a>
<span class="sourceLineNo">1631</span><a name="line.1631"></a>
<span class="sourceLineNo">1632</span>        // are we using the chart buffer?<a name="line.1632"></a>
<span class="sourceLineNo">1633</span>        if (this.useBuffer) {<a name="line.1633"></a>
<span class="sourceLineNo">1634</span><a name="line.1634"></a>
<span class="sourceLineNo">1635</span>            // do we need to resize the buffer?<a name="line.1635"></a>
<span class="sourceLineNo">1636</span>            if ((this.chartBuffer == null)<a name="line.1636"></a>
<span class="sourceLineNo">1637</span>                    || (this.chartBufferWidth != available.getWidth())<a name="line.1637"></a>
<span class="sourceLineNo">1638</span>                    || (this.chartBufferHeight != available.getHeight())) {<a name="line.1638"></a>
<span class="sourceLineNo">1639</span>                this.chartBufferWidth = (int) available.getWidth();<a name="line.1639"></a>
<span class="sourceLineNo">1640</span>                this.chartBufferHeight = (int) available.getHeight();<a name="line.1640"></a>
<span class="sourceLineNo">1641</span>                GraphicsConfiguration gc = g2.getDeviceConfiguration();<a name="line.1641"></a>
<span class="sourceLineNo">1642</span>                this.chartBuffer = gc.createCompatibleImage(<a name="line.1642"></a>
<span class="sourceLineNo">1643</span>                        this.chartBufferWidth, this.chartBufferHeight,<a name="line.1643"></a>
<span class="sourceLineNo">1644</span>                        Transparency.TRANSLUCENT);<a name="line.1644"></a>
<span class="sourceLineNo">1645</span>                this.refreshBuffer = true;<a name="line.1645"></a>
<span class="sourceLineNo">1646</span>            }<a name="line.1646"></a>
<span class="sourceLineNo">1647</span><a name="line.1647"></a>
<span class="sourceLineNo">1648</span>            // do we need to redraw the buffer?<a name="line.1648"></a>
<span class="sourceLineNo">1649</span>            if (this.refreshBuffer) {<a name="line.1649"></a>
<span class="sourceLineNo">1650</span><a name="line.1650"></a>
<span class="sourceLineNo">1651</span>                this.refreshBuffer = false; // clear the flag<a name="line.1651"></a>
<span class="sourceLineNo">1652</span><a name="line.1652"></a>
<span class="sourceLineNo">1653</span>                Rectangle2D bufferArea = new Rectangle2D.Double(<a name="line.1653"></a>
<span class="sourceLineNo">1654</span>                        0, 0, this.chartBufferWidth, this.chartBufferHeight);<a name="line.1654"></a>
<span class="sourceLineNo">1655</span><a name="line.1655"></a>
<span class="sourceLineNo">1656</span>                // make the background of the buffer clear and transparent<a name="line.1656"></a>
<span class="sourceLineNo">1657</span>                Graphics2D bufferG2 = (Graphics2D)<a name="line.1657"></a>
<span class="sourceLineNo">1658</span>                        this.chartBuffer.getGraphics();<a name="line.1658"></a>
<span class="sourceLineNo">1659</span>                Composite savedComposite = bufferG2.getComposite();<a name="line.1659"></a>
<span class="sourceLineNo">1660</span>                bufferG2.setComposite(AlphaComposite.getInstance(<a name="line.1660"></a>
<span class="sourceLineNo">1661</span>                        AlphaComposite.CLEAR, 0.0f));<a name="line.1661"></a>
<span class="sourceLineNo">1662</span>                Rectangle r = new Rectangle(0, 0, this.chartBufferWidth,<a name="line.1662"></a>
<span class="sourceLineNo">1663</span>                        this.chartBufferHeight);<a name="line.1663"></a>
<span class="sourceLineNo">1664</span>                bufferG2.fill(r);<a name="line.1664"></a>
<span class="sourceLineNo">1665</span>                bufferG2.setComposite(savedComposite);<a name="line.1665"></a>
<span class="sourceLineNo">1666</span>                <a name="line.1666"></a>
<span class="sourceLineNo">1667</span>                if (scale) {<a name="line.1667"></a>
<span class="sourceLineNo">1668</span>                    AffineTransform saved = bufferG2.getTransform();<a name="line.1668"></a>
<span class="sourceLineNo">1669</span>                    AffineTransform st = AffineTransform.getScaleInstance(<a name="line.1669"></a>
<span class="sourceLineNo">1670</span>                            this.scaleX, this.scaleY);<a name="line.1670"></a>
<span class="sourceLineNo">1671</span>                    bufferG2.transform(st);<a name="line.1671"></a>
<span class="sourceLineNo">1672</span>                    this.chart.draw(bufferG2, chartArea, this.anchor,<a name="line.1672"></a>
<span class="sourceLineNo">1673</span>                            this.info);<a name="line.1673"></a>
<span class="sourceLineNo">1674</span>                    bufferG2.setTransform(saved);<a name="line.1674"></a>
<span class="sourceLineNo">1675</span>                }<a name="line.1675"></a>
<span class="sourceLineNo">1676</span>                else {<a name="line.1676"></a>
<span class="sourceLineNo">1677</span>                    this.chart.draw(bufferG2, bufferArea, this.anchor,<a name="line.1677"></a>
<span class="sourceLineNo">1678</span>                            this.info);<a name="line.1678"></a>
<span class="sourceLineNo">1679</span>                }<a name="line.1679"></a>
<span class="sourceLineNo">1680</span><a name="line.1680"></a>
<span class="sourceLineNo">1681</span>            }<a name="line.1681"></a>
<span class="sourceLineNo">1682</span><a name="line.1682"></a>
<span class="sourceLineNo">1683</span>            // zap the buffer onto the panel...<a name="line.1683"></a>
<span class="sourceLineNo">1684</span>            g2.drawImage(this.chartBuffer, insets.left, insets.top, this);<a name="line.1684"></a>
<span class="sourceLineNo">1685</span><a name="line.1685"></a>
<span class="sourceLineNo">1686</span>        }<a name="line.1686"></a>
<span class="sourceLineNo">1687</span><a name="line.1687"></a>
<span class="sourceLineNo">1688</span>        // or redrawing the chart every time...<a name="line.1688"></a>
<span class="sourceLineNo">1689</span>        else {<a name="line.1689"></a>
<span class="sourceLineNo">1690</span><a name="line.1690"></a>
<span class="sourceLineNo">1691</span>            AffineTransform saved = g2.getTransform();<a name="line.1691"></a>
<span class="sourceLineNo">1692</span>            g2.translate(insets.left, insets.top);<a name="line.1692"></a>
<span class="sourceLineNo">1693</span>            if (scale) {<a name="line.1693"></a>
<span class="sourceLineNo">1694</span>                AffineTransform st = AffineTransform.getScaleInstance(<a name="line.1694"></a>
<span class="sourceLineNo">1695</span>                        this.scaleX, this.scaleY);<a name="line.1695"></a>
<span class="sourceLineNo">1696</span>                g2.transform(st);<a name="line.1696"></a>
<span class="sourceLineNo">1697</span>            }<a name="line.1697"></a>
<span class="sourceLineNo">1698</span>            this.chart.draw(g2, chartArea, this.anchor, this.info);<a name="line.1698"></a>
<span class="sourceLineNo">1699</span>            g2.setTransform(saved);<a name="line.1699"></a>
<span class="sourceLineNo">1700</span><a name="line.1700"></a>
<span class="sourceLineNo">1701</span>        }<a name="line.1701"></a>
<span class="sourceLineNo">1702</span><a name="line.1702"></a>
<span class="sourceLineNo">1703</span>        Iterator iterator = this.overlays.iterator();<a name="line.1703"></a>
<span class="sourceLineNo">1704</span>        while (iterator.hasNext()) {<a name="line.1704"></a>
<span class="sourceLineNo">1705</span>            Overlay overlay = (Overlay) iterator.next();<a name="line.1705"></a>
<span class="sourceLineNo">1706</span>            overlay.paintOverlay(g2, this);<a name="line.1706"></a>
<span class="sourceLineNo">1707</span>        }<a name="line.1707"></a>
<span class="sourceLineNo">1708</span><a name="line.1708"></a>
<span class="sourceLineNo">1709</span>        // redraw the zoom rectangle (if present) - if useBuffer is false,<a name="line.1709"></a>
<span class="sourceLineNo">1710</span>        // we use XOR so we can XOR the rectangle away again without redrawing<a name="line.1710"></a>
<span class="sourceLineNo">1711</span>        // the chart<a name="line.1711"></a>
<span class="sourceLineNo">1712</span>        drawZoomRectangle(g2, !this.useBuffer);<a name="line.1712"></a>
<span class="sourceLineNo">1713</span><a name="line.1713"></a>
<span class="sourceLineNo">1714</span>        g2.dispose();<a name="line.1714"></a>
<span class="sourceLineNo">1715</span><a name="line.1715"></a>
<span class="sourceLineNo">1716</span>        this.anchor = null;<a name="line.1716"></a>
<span class="sourceLineNo">1717</span>        this.verticalTraceLine = null;<a name="line.1717"></a>
<span class="sourceLineNo">1718</span>        this.horizontalTraceLine = null;<a name="line.1718"></a>
<span class="sourceLineNo">1719</span><a name="line.1719"></a>
<span class="sourceLineNo">1720</span>    }<a name="line.1720"></a>
<span class="sourceLineNo">1721</span><a name="line.1721"></a>
<span class="sourceLineNo">1722</span>    /**<a name="line.1722"></a>
<span class="sourceLineNo">1723</span>     * Receives notification of changes to the chart, and redraws the chart.<a name="line.1723"></a>
<span class="sourceLineNo">1724</span>     *<a name="line.1724"></a>
<span class="sourceLineNo">1725</span>     * @param event  details of the chart change event.<a name="line.1725"></a>
<span class="sourceLineNo">1726</span>     */<a name="line.1726"></a>
<span class="sourceLineNo">1727</span>    public void chartChanged(ChartChangeEvent event) {<a name="line.1727"></a>
<span class="sourceLineNo">1728</span>        this.refreshBuffer = true;<a name="line.1728"></a>
<span class="sourceLineNo">1729</span>        Plot plot = this.chart.getPlot();<a name="line.1729"></a>
<span class="sourceLineNo">1730</span>        if (plot instanceof Zoomable) {<a name="line.1730"></a>
<span class="sourceLineNo">1731</span>            Zoomable z = (Zoomable) plot;<a name="line.1731"></a>
<span class="sourceLineNo">1732</span>            this.orientation = z.getOrientation();<a name="line.1732"></a>
<span class="sourceLineNo">1733</span>        }<a name="line.1733"></a>
<span class="sourceLineNo">1734</span>        repaint();<a name="line.1734"></a>
<span class="sourceLineNo">1735</span>    }<a name="line.1735"></a>
<span class="sourceLineNo">1736</span><a name="line.1736"></a>
<span class="sourceLineNo">1737</span>    /**<a name="line.1737"></a>
<span class="sourceLineNo">1738</span>     * Receives notification of a chart progress event.<a name="line.1738"></a>
<span class="sourceLineNo">1739</span>     *<a name="line.1739"></a>
<span class="sourceLineNo">1740</span>     * @param event  the event.<a name="line.1740"></a>
<span class="sourceLineNo">1741</span>     */<a name="line.1741"></a>
<span class="sourceLineNo">1742</span>    public void chartProgress(ChartProgressEvent event) {<a name="line.1742"></a>
<span class="sourceLineNo">1743</span>        // does nothing - override if necessary<a name="line.1743"></a>
<span class="sourceLineNo">1744</span>    }<a name="line.1744"></a>
<span class="sourceLineNo">1745</span><a name="line.1745"></a>
<span class="sourceLineNo">1746</span>    /**<a name="line.1746"></a>
<span class="sourceLineNo">1747</span>     * Handles action events generated by the popup menu.<a name="line.1747"></a>
<span class="sourceLineNo">1748</span>     *<a name="line.1748"></a>
<span class="sourceLineNo">1749</span>     * @param event  the event.<a name="line.1749"></a>
<span class="sourceLineNo">1750</span>     */<a name="line.1750"></a>
<span class="sourceLineNo">1751</span>    public void actionPerformed(ActionEvent event) {<a name="line.1751"></a>
<span class="sourceLineNo">1752</span><a name="line.1752"></a>
<span class="sourceLineNo">1753</span>        String command = event.getActionCommand();<a name="line.1753"></a>
<span class="sourceLineNo">1754</span><a name="line.1754"></a>
<span class="sourceLineNo">1755</span>        // many of the zoom methods need a screen location - all we have is<a name="line.1755"></a>
<span class="sourceLineNo">1756</span>        // the zoomPoint, but it might be null.  Here we grab the x and y<a name="line.1756"></a>
<span class="sourceLineNo">1757</span>        // coordinates, or use defaults...<a name="line.1757"></a>
<span class="sourceLineNo">1758</span>        double screenX = -1.0;<a name="line.1758"></a>
<span class="sourceLineNo">1759</span>        double screenY = -1.0;<a name="line.1759"></a>
<span class="sourceLineNo">1760</span>        if (this.zoomPoint != null) {<a name="line.1760"></a>
<span class="sourceLineNo">1761</span>            screenX = this.zoomPoint.getX();<a name="line.1761"></a>
<span class="sourceLineNo">1762</span>            screenY = this.zoomPoint.getY();<a name="line.1762"></a>
<span class="sourceLineNo">1763</span>        }<a name="line.1763"></a>
<span class="sourceLineNo">1764</span><a name="line.1764"></a>
<span class="sourceLineNo">1765</span>        if (command.equals(PROPERTIES_COMMAND)) {<a name="line.1765"></a>
<span class="sourceLineNo">1766</span>            doEditChartProperties();<a name="line.1766"></a>
<span class="sourceLineNo">1767</span>        }<a name="line.1767"></a>
<span class="sourceLineNo">1768</span>        else if (command.equals(COPY_COMMAND)) {<a name="line.1768"></a>
<span class="sourceLineNo">1769</span>            doCopy();<a name="line.1769"></a>
<span class="sourceLineNo">1770</span>        }<a name="line.1770"></a>
<span class="sourceLineNo">1771</span>        else if (command.equals(SAVE_COMMAND)) {<a name="line.1771"></a>
<span class="sourceLineNo">1772</span>            try {<a name="line.1772"></a>
<span class="sourceLineNo">1773</span>                doSaveAs();<a name="line.1773"></a>
<span class="sourceLineNo">1774</span>            }<a name="line.1774"></a>
<span class="sourceLineNo">1775</span>            catch (IOException e) {<a name="line.1775"></a>
<span class="sourceLineNo">1776</span>                e.printStackTrace();<a name="line.1776"></a>
<span class="sourceLineNo">1777</span>            }<a name="line.1777"></a>
<span class="sourceLineNo">1778</span>        }<a name="line.1778"></a>
<span class="sourceLineNo">1779</span>        else if (command.equals(PRINT_COMMAND)) {<a name="line.1779"></a>
<span class="sourceLineNo">1780</span>            createChartPrintJob();<a name="line.1780"></a>
<span class="sourceLineNo">1781</span>        }<a name="line.1781"></a>
<span class="sourceLineNo">1782</span>        else if (command.equals(ZOOM_IN_BOTH_COMMAND)) {<a name="line.1782"></a>
<span class="sourceLineNo">1783</span>            zoomInBoth(screenX, screenY);<a name="line.1783"></a>
<span class="sourceLineNo">1784</span>        }<a name="line.1784"></a>
<span class="sourceLineNo">1785</span>        else if (command.equals(ZOOM_IN_DOMAIN_COMMAND)) {<a name="line.1785"></a>
<span class="sourceLineNo">1786</span>            zoomInDomain(screenX, screenY);<a name="line.1786"></a>
<span class="sourceLineNo">1787</span>        }<a name="line.1787"></a>
<span class="sourceLineNo">1788</span>        else if (command.equals(ZOOM_IN_RANGE_COMMAND)) {<a name="line.1788"></a>
<span class="sourceLineNo">1789</span>            zoomInRange(screenX, screenY);<a name="line.1789"></a>
<span class="sourceLineNo">1790</span>        }<a name="line.1790"></a>
<span class="sourceLineNo">1791</span>        else if (command.equals(ZOOM_OUT_BOTH_COMMAND)) {<a name="line.1791"></a>
<span class="sourceLineNo">1792</span>            zoomOutBoth(screenX, screenY);<a name="line.1792"></a>
<span class="sourceLineNo">1793</span>        }<a name="line.1793"></a>
<span class="sourceLineNo">1794</span>        else if (command.equals(ZOOM_OUT_DOMAIN_COMMAND)) {<a name="line.1794"></a>
<span class="sourceLineNo">1795</span>            zoomOutDomain(screenX, screenY);<a name="line.1795"></a>
<span class="sourceLineNo">1796</span>        }<a name="line.1796"></a>
<span class="sourceLineNo">1797</span>        else if (command.equals(ZOOM_OUT_RANGE_COMMAND)) {<a name="line.1797"></a>
<span class="sourceLineNo">1798</span>            zoomOutRange(screenX, screenY);<a name="line.1798"></a>
<span class="sourceLineNo">1799</span>        }<a name="line.1799"></a>
<span class="sourceLineNo">1800</span>        else if (command.equals(ZOOM_RESET_BOTH_COMMAND)) {<a name="line.1800"></a>
<span class="sourceLineNo">1801</span>            restoreAutoBounds();<a name="line.1801"></a>
<span class="sourceLineNo">1802</span>        }<a name="line.1802"></a>
<span class="sourceLineNo">1803</span>        else if (command.equals(ZOOM_RESET_DOMAIN_COMMAND)) {<a name="line.1803"></a>
<span class="sourceLineNo">1804</span>            restoreAutoDomainBounds();<a name="line.1804"></a>
<span class="sourceLineNo">1805</span>        }<a name="line.1805"></a>
<span class="sourceLineNo">1806</span>        else if (command.equals(ZOOM_RESET_RANGE_COMMAND)) {<a name="line.1806"></a>
<span class="sourceLineNo">1807</span>            restoreAutoRangeBounds();<a name="line.1807"></a>
<span class="sourceLineNo">1808</span>        }<a name="line.1808"></a>
<span class="sourceLineNo">1809</span><a name="line.1809"></a>
<span class="sourceLineNo">1810</span>    }<a name="line.1810"></a>
<span class="sourceLineNo">1811</span><a name="line.1811"></a>
<span class="sourceLineNo">1812</span>    /**<a name="line.1812"></a>
<span class="sourceLineNo">1813</span>     * Handles a 'mouse entered' event. This method changes the tooltip delays<a name="line.1813"></a>
<span class="sourceLineNo">1814</span>     * of ToolTipManager.sharedInstance() to the possibly different values set<a name="line.1814"></a>
<span class="sourceLineNo">1815</span>     * for this chart panel.<a name="line.1815"></a>
<span class="sourceLineNo">1816</span>     *<a name="line.1816"></a>
<span class="sourceLineNo">1817</span>     * @param e  the mouse event.<a name="line.1817"></a>
<span class="sourceLineNo">1818</span>     */<a name="line.1818"></a>
<span class="sourceLineNo">1819</span>    public void mouseEntered(MouseEvent e) {<a name="line.1819"></a>
<span class="sourceLineNo">1820</span>        if (!this.ownToolTipDelaysActive) {<a name="line.1820"></a>
<span class="sourceLineNo">1821</span>            ToolTipManager ttm = ToolTipManager.sharedInstance();<a name="line.1821"></a>
<span class="sourceLineNo">1822</span><a name="line.1822"></a>
<span class="sourceLineNo">1823</span>            this.originalToolTipInitialDelay = ttm.getInitialDelay();<a name="line.1823"></a>
<span class="sourceLineNo">1824</span>            ttm.setInitialDelay(this.ownToolTipInitialDelay);<a name="line.1824"></a>
<span class="sourceLineNo">1825</span><a name="line.1825"></a>
<span class="sourceLineNo">1826</span>            this.originalToolTipReshowDelay = ttm.getReshowDelay();<a name="line.1826"></a>
<span class="sourceLineNo">1827</span>            ttm.setReshowDelay(this.ownToolTipReshowDelay);<a name="line.1827"></a>
<span class="sourceLineNo">1828</span><a name="line.1828"></a>
<span class="sourceLineNo">1829</span>            this.originalToolTipDismissDelay = ttm.getDismissDelay();<a name="line.1829"></a>
<span class="sourceLineNo">1830</span>            ttm.setDismissDelay(this.ownToolTipDismissDelay);<a name="line.1830"></a>
<span class="sourceLineNo">1831</span><a name="line.1831"></a>
<span class="sourceLineNo">1832</span>            this.ownToolTipDelaysActive = true;<a name="line.1832"></a>
<span class="sourceLineNo">1833</span>        }<a name="line.1833"></a>
<span class="sourceLineNo">1834</span>    }<a name="line.1834"></a>
<span class="sourceLineNo">1835</span><a name="line.1835"></a>
<span class="sourceLineNo">1836</span>    /**<a name="line.1836"></a>
<span class="sourceLineNo">1837</span>     * Handles a 'mouse exited' event. This method resets the tooltip delays of<a name="line.1837"></a>
<span class="sourceLineNo">1838</span>     * ToolTipManager.sharedInstance() to their<a name="line.1838"></a>
<span class="sourceLineNo">1839</span>     * original values in effect before mouseEntered()<a name="line.1839"></a>
<span class="sourceLineNo">1840</span>     *<a name="line.1840"></a>
<span class="sourceLineNo">1841</span>     * @param e  the mouse event.<a name="line.1841"></a>
<span class="sourceLineNo">1842</span>     */<a name="line.1842"></a>
<span class="sourceLineNo">1843</span>    public void mouseExited(MouseEvent e) {<a name="line.1843"></a>
<span class="sourceLineNo">1844</span>        if (this.ownToolTipDelaysActive) {<a name="line.1844"></a>
<span class="sourceLineNo">1845</span>            // restore original tooltip dealys<a name="line.1845"></a>
<span class="sourceLineNo">1846</span>            ToolTipManager ttm = ToolTipManager.sharedInstance();<a name="line.1846"></a>
<span class="sourceLineNo">1847</span>            ttm.setInitialDelay(this.originalToolTipInitialDelay);<a name="line.1847"></a>
<span class="sourceLineNo">1848</span>            ttm.setReshowDelay(this.originalToolTipReshowDelay);<a name="line.1848"></a>
<span class="sourceLineNo">1849</span>            ttm.setDismissDelay(this.originalToolTipDismissDelay);<a name="line.1849"></a>
<span class="sourceLineNo">1850</span>            this.ownToolTipDelaysActive = false;<a name="line.1850"></a>
<span class="sourceLineNo">1851</span>        }<a name="line.1851"></a>
<span class="sourceLineNo">1852</span>    }<a name="line.1852"></a>
<span class="sourceLineNo">1853</span><a name="line.1853"></a>
<span class="sourceLineNo">1854</span>    /**<a name="line.1854"></a>
<span class="sourceLineNo">1855</span>     * Handles a 'mouse pressed' event.<a name="line.1855"></a>
<span class="sourceLineNo">1856</span>     * &lt;P&gt;<a name="line.1856"></a>
<span class="sourceLineNo">1857</span>     * This event is the popup trigger on Unix/Linux.  For Windows, the popup<a name="line.1857"></a>
<span class="sourceLineNo">1858</span>     * trigger is the 'mouse released' event.<a name="line.1858"></a>
<span class="sourceLineNo">1859</span>     *<a name="line.1859"></a>
<span class="sourceLineNo">1860</span>     * @param e  The mouse event.<a name="line.1860"></a>
<span class="sourceLineNo">1861</span>     */<a name="line.1861"></a>
<span class="sourceLineNo">1862</span>    public void mousePressed(MouseEvent e) {<a name="line.1862"></a>
<span class="sourceLineNo">1863</span>        if (this.chart == null) {<a name="line.1863"></a>
<span class="sourceLineNo">1864</span>            return;<a name="line.1864"></a>
<span class="sourceLineNo">1865</span>        }<a name="line.1865"></a>
<span class="sourceLineNo">1866</span>        Plot plot = this.chart.getPlot();<a name="line.1866"></a>
<span class="sourceLineNo">1867</span>        int mods = e.getModifiers();<a name="line.1867"></a>
<span class="sourceLineNo">1868</span>        if ((mods &amp; this.panMask) == this.panMask) {<a name="line.1868"></a>
<span class="sourceLineNo">1869</span>            // can we pan this plot?<a name="line.1869"></a>
<span class="sourceLineNo">1870</span>            if (plot instanceof Pannable) {<a name="line.1870"></a>
<span class="sourceLineNo">1871</span>                Pannable pannable = (Pannable) plot;<a name="line.1871"></a>
<span class="sourceLineNo">1872</span>                if (pannable.isDomainPannable() || pannable.isRangePannable()) {<a name="line.1872"></a>
<span class="sourceLineNo">1873</span>                    Rectangle2D screenDataArea = getScreenDataArea(e.getX(),<a name="line.1873"></a>
<span class="sourceLineNo">1874</span>                            e.getY());<a name="line.1874"></a>
<span class="sourceLineNo">1875</span>                    if (screenDataArea != null &amp;&amp; screenDataArea.contains(<a name="line.1875"></a>
<span class="sourceLineNo">1876</span>                            e.getPoint())) {<a name="line.1876"></a>
<span class="sourceLineNo">1877</span>                        this.panW = screenDataArea.getWidth();<a name="line.1877"></a>
<span class="sourceLineNo">1878</span>                        this.panH = screenDataArea.getHeight();<a name="line.1878"></a>
<span class="sourceLineNo">1879</span>                        this.panLast = e.getPoint();<a name="line.1879"></a>
<span class="sourceLineNo">1880</span>                        setCursor(Cursor.getPredefinedCursor(<a name="line.1880"></a>
<span class="sourceLineNo">1881</span>                                Cursor.MOVE_CURSOR));<a name="line.1881"></a>
<span class="sourceLineNo">1882</span>                    }<a name="line.1882"></a>
<span class="sourceLineNo">1883</span>                }<a name="line.1883"></a>
<span class="sourceLineNo">1884</span>                // the actual panning occurs later in the mouseDragged() <a name="line.1884"></a>
<span class="sourceLineNo">1885</span>                // method<a name="line.1885"></a>
<span class="sourceLineNo">1886</span>            }<a name="line.1886"></a>
<span class="sourceLineNo">1887</span>        }<a name="line.1887"></a>
<span class="sourceLineNo">1888</span>        else if (this.zoomRectangle == null) {<a name="line.1888"></a>
<span class="sourceLineNo">1889</span>            Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY());<a name="line.1889"></a>
<span class="sourceLineNo">1890</span>            if (screenDataArea != null) {<a name="line.1890"></a>
<span class="sourceLineNo">1891</span>                this.zoomPoint = getPointInRectangle(e.getX(), e.getY(),<a name="line.1891"></a>
<span class="sourceLineNo">1892</span>                        screenDataArea);<a name="line.1892"></a>
<span class="sourceLineNo">1893</span>            }<a name="line.1893"></a>
<span class="sourceLineNo">1894</span>            else {<a name="line.1894"></a>
<span class="sourceLineNo">1895</span>                this.zoomPoint = null;<a name="line.1895"></a>
<span class="sourceLineNo">1896</span>            }<a name="line.1896"></a>
<span class="sourceLineNo">1897</span>            if (e.isPopupTrigger()) {<a name="line.1897"></a>
<span class="sourceLineNo">1898</span>                if (this.popup != null) {<a name="line.1898"></a>
<span class="sourceLineNo">1899</span>                    displayPopupMenu(e.getX(), e.getY());<a name="line.1899"></a>
<span class="sourceLineNo">1900</span>                }<a name="line.1900"></a>
<span class="sourceLineNo">1901</span>            }<a name="line.1901"></a>
<span class="sourceLineNo">1902</span>        }<a name="line.1902"></a>
<span class="sourceLineNo">1903</span>    }<a name="line.1903"></a>
<span class="sourceLineNo">1904</span><a name="line.1904"></a>
<span class="sourceLineNo">1905</span>    /**<a name="line.1905"></a>
<span class="sourceLineNo">1906</span>     * Returns a point based on (x, y) but constrained to be within the bounds<a name="line.1906"></a>
<span class="sourceLineNo">1907</span>     * of the given rectangle.  This method could be moved to JCommon.<a name="line.1907"></a>
<span class="sourceLineNo">1908</span>     *<a name="line.1908"></a>
<span class="sourceLineNo">1909</span>     * @param x  the x-coordinate.<a name="line.1909"></a>
<span class="sourceLineNo">1910</span>     * @param y  the y-coordinate.<a name="line.1910"></a>
<span class="sourceLineNo">1911</span>     * @param area  the rectangle (&lt;code&gt;null&lt;/code&gt; not permitted).<a name="line.1911"></a>
<span class="sourceLineNo">1912</span>     *<a name="line.1912"></a>
<span class="sourceLineNo">1913</span>     * @return A point within the rectangle.<a name="line.1913"></a>
<span class="sourceLineNo">1914</span>     */<a name="line.1914"></a>
<span class="sourceLineNo">1915</span>    private Point2D getPointInRectangle(int x, int y, Rectangle2D area) {<a name="line.1915"></a>
<span class="sourceLineNo">1916</span>        double xx = Math.max(area.getMinX(), Math.min(x, area.getMaxX()));<a name="line.1916"></a>
<span class="sourceLineNo">1917</span>        double yy = Math.max(area.getMinY(), Math.min(y, area.getMaxY()));<a name="line.1917"></a>
<span class="sourceLineNo">1918</span>        return new Point2D.Double(xx, yy);<a name="line.1918"></a>
<span class="sourceLineNo">1919</span>    }<a name="line.1919"></a>
<span class="sourceLineNo">1920</span><a name="line.1920"></a>
<span class="sourceLineNo">1921</span>    /**<a name="line.1921"></a>
<span class="sourceLineNo">1922</span>     * Handles a 'mouse dragged' event.<a name="line.1922"></a>
<span class="sourceLineNo">1923</span>     *<a name="line.1923"></a>
<span class="sourceLineNo">1924</span>     * @param e  the mouse event.<a name="line.1924"></a>
<span class="sourceLineNo">1925</span>     */<a name="line.1925"></a>
<span class="sourceLineNo">1926</span>    public void mouseDragged(MouseEvent e) {<a name="line.1926"></a>
<span class="sourceLineNo">1927</span><a name="line.1927"></a>
<span class="sourceLineNo">1928</span>        // if the popup menu has already been triggered, then ignore dragging...<a name="line.1928"></a>
<span class="sourceLineNo">1929</span>        if (this.popup != null &amp;&amp; this.popup.isShowing()) {<a name="line.1929"></a>
<span class="sourceLineNo">1930</span>            return;<a name="line.1930"></a>
<span class="sourceLineNo">1931</span>        }<a name="line.1931"></a>
<span class="sourceLineNo">1932</span><a name="line.1932"></a>
<span class="sourceLineNo">1933</span>        // handle panning if we have a start point<a name="line.1933"></a>
<span class="sourceLineNo">1934</span>        if (this.panLast != null) {<a name="line.1934"></a>
<span class="sourceLineNo">1935</span>            double dx = e.getX() - this.panLast.getX();<a name="line.1935"></a>
<span class="sourceLineNo">1936</span>            double dy = e.getY() - this.panLast.getY();<a name="line.1936"></a>
<span class="sourceLineNo">1937</span>            if (dx == 0.0 &amp;&amp; dy == 0.0) {<a name="line.1937"></a>
<span class="sourceLineNo">1938</span>                return;<a name="line.1938"></a>
<span class="sourceLineNo">1939</span>            }<a name="line.1939"></a>
<span class="sourceLineNo">1940</span>            double wPercent = -dx / this.panW;<a name="line.1940"></a>
<span class="sourceLineNo">1941</span>            double hPercent = dy / this.panH;<a name="line.1941"></a>
<span class="sourceLineNo">1942</span>            boolean old = this.chart.getPlot().isNotify();<a name="line.1942"></a>
<span class="sourceLineNo">1943</span>            this.chart.getPlot().setNotify(false);<a name="line.1943"></a>
<span class="sourceLineNo">1944</span>            Pannable p = (Pannable) this.chart.getPlot();<a name="line.1944"></a>
<span class="sourceLineNo">1945</span>            if (p.getOrientation() == PlotOrientation.VERTICAL) {<a name="line.1945"></a>
<span class="sourceLineNo">1946</span>                p.panDomainAxes(wPercent, this.info.getPlotInfo(),<a name="line.1946"></a>
<span class="sourceLineNo">1947</span>                        this.panLast);<a name="line.1947"></a>
<span class="sourceLineNo">1948</span>                p.panRangeAxes(hPercent, this.info.getPlotInfo(),<a name="line.1948"></a>
<span class="sourceLineNo">1949</span>                        this.panLast);<a name="line.1949"></a>
<span class="sourceLineNo">1950</span>            }<a name="line.1950"></a>
<span class="sourceLineNo">1951</span>            else {<a name="line.1951"></a>
<span class="sourceLineNo">1952</span>                p.panDomainAxes(hPercent, this.info.getPlotInfo(),<a name="line.1952"></a>
<span class="sourceLineNo">1953</span>                        this.panLast);<a name="line.1953"></a>
<span class="sourceLineNo">1954</span>                p.panRangeAxes(wPercent, this.info.getPlotInfo(),<a name="line.1954"></a>
<span class="sourceLineNo">1955</span>                        this.panLast);<a name="line.1955"></a>
<span class="sourceLineNo">1956</span>            }<a name="line.1956"></a>
<span class="sourceLineNo">1957</span>            this.panLast = e.getPoint();<a name="line.1957"></a>
<span class="sourceLineNo">1958</span>            this.chart.getPlot().setNotify(old);<a name="line.1958"></a>
<span class="sourceLineNo">1959</span>            return;<a name="line.1959"></a>
<span class="sourceLineNo">1960</span>        }<a name="line.1960"></a>
<span class="sourceLineNo">1961</span><a name="line.1961"></a>
<span class="sourceLineNo">1962</span>        // if no initial zoom point was set, ignore dragging...<a name="line.1962"></a>
<span class="sourceLineNo">1963</span>        if (this.zoomPoint == null) {<a name="line.1963"></a>
<span class="sourceLineNo">1964</span>            return;<a name="line.1964"></a>
<span class="sourceLineNo">1965</span>        }<a name="line.1965"></a>
<span class="sourceLineNo">1966</span>        Graphics2D g2 = (Graphics2D) getGraphics();<a name="line.1966"></a>
<span class="sourceLineNo">1967</span><a name="line.1967"></a>
<span class="sourceLineNo">1968</span>        // erase the previous zoom rectangle (if any).  We only need to do<a name="line.1968"></a>
<span class="sourceLineNo">1969</span>        // this is we are using XOR mode, which we do when we're not using<a name="line.1969"></a>
<span class="sourceLineNo">1970</span>        // the buffer (if there is a buffer, then at the end of this method we<a name="line.1970"></a>
<span class="sourceLineNo">1971</span>        // just trigger a repaint)<a name="line.1971"></a>
<span class="sourceLineNo">1972</span>        if (!this.useBuffer) {<a name="line.1972"></a>
<span class="sourceLineNo">1973</span>            drawZoomRectangle(g2, true);<a name="line.1973"></a>
<span class="sourceLineNo">1974</span>        }<a name="line.1974"></a>
<span class="sourceLineNo">1975</span><a name="line.1975"></a>
<span class="sourceLineNo">1976</span>        boolean hZoom = false;<a name="line.1976"></a>
<span class="sourceLineNo">1977</span>        boolean vZoom = false;<a name="line.1977"></a>
<span class="sourceLineNo">1978</span>        if (this.orientation == PlotOrientation.HORIZONTAL) {<a name="line.1978"></a>
<span class="sourceLineNo">1979</span>            hZoom = this.rangeZoomable;<a name="line.1979"></a>
<span class="sourceLineNo">1980</span>            vZoom = this.domainZoomable;<a name="line.1980"></a>
<span class="sourceLineNo">1981</span>        }<a name="line.1981"></a>
<span class="sourceLineNo">1982</span>        else {<a name="line.1982"></a>
<span class="sourceLineNo">1983</span>            hZoom = this.domainZoomable;<a name="line.1983"></a>
<span class="sourceLineNo">1984</span>            vZoom = this.rangeZoomable;<a name="line.1984"></a>
<span class="sourceLineNo">1985</span>        }<a name="line.1985"></a>
<span class="sourceLineNo">1986</span>        Rectangle2D scaledDataArea = getScreenDataArea(<a name="line.1986"></a>
<span class="sourceLineNo">1987</span>                (int) this.zoomPoint.getX(), (int) this.zoomPoint.getY());<a name="line.1987"></a>
<span class="sourceLineNo">1988</span>        if (hZoom &amp;&amp; vZoom) {<a name="line.1988"></a>
<span class="sourceLineNo">1989</span>            // selected rectangle shouldn't extend outside the data area...<a name="line.1989"></a>
<span class="sourceLineNo">1990</span>            double xmax = Math.min(e.getX(), scaledDataArea.getMaxX());<a name="line.1990"></a>
<span class="sourceLineNo">1991</span>            double ymax = Math.min(e.getY(), scaledDataArea.getMaxY());<a name="line.1991"></a>
<span class="sourceLineNo">1992</span>            this.zoomRectangle = new Rectangle2D.Double(<a name="line.1992"></a>
<span class="sourceLineNo">1993</span>                    this.zoomPoint.getX(), this.zoomPoint.getY(),<a name="line.1993"></a>
<span class="sourceLineNo">1994</span>                    xmax - this.zoomPoint.getX(), ymax - this.zoomPoint.getY());<a name="line.1994"></a>
<span class="sourceLineNo">1995</span>        }<a name="line.1995"></a>
<span class="sourceLineNo">1996</span>        else if (hZoom) {<a name="line.1996"></a>
<span class="sourceLineNo">1997</span>            double xmax = Math.min(e.getX(), scaledDataArea.getMaxX());<a name="line.1997"></a>
<span class="sourceLineNo">1998</span>            this.zoomRectangle = new Rectangle2D.Double(<a name="line.1998"></a>
<span class="sourceLineNo">1999</span>                    this.zoomPoint.getX(), scaledDataArea.getMinY(),<a name="line.1999"></a>
<span class="sourceLineNo">2000</span>                    xmax - this.zoomPoint.getX(), scaledDataArea.getHeight());<a name="line.2000"></a>
<span class="sourceLineNo">2001</span>        }<a name="line.2001"></a>
<span class="sourceLineNo">2002</span>        else if (vZoom) {<a name="line.2002"></a>
<span class="sourceLineNo">2003</span>            double ymax = Math.min(e.getY(), scaledDataArea.getMaxY());<a name="line.2003"></a>
<span class="sourceLineNo">2004</span>            this.zoomRectangle = new Rectangle2D.Double(<a name="line.2004"></a>
<span class="sourceLineNo">2005</span>                    scaledDataArea.getMinX(), this.zoomPoint.getY(),<a name="line.2005"></a>
<span class="sourceLineNo">2006</span>                    scaledDataArea.getWidth(), ymax - this.zoomPoint.getY());<a name="line.2006"></a>
<span class="sourceLineNo">2007</span>        }<a name="line.2007"></a>
<span class="sourceLineNo">2008</span><a name="line.2008"></a>
<span class="sourceLineNo">2009</span>        // Draw the new zoom rectangle...<a name="line.2009"></a>
<span class="sourceLineNo">2010</span>        if (this.useBuffer) {<a name="line.2010"></a>
<span class="sourceLineNo">2011</span>            repaint();<a name="line.2011"></a>
<span class="sourceLineNo">2012</span>        }<a name="line.2012"></a>
<span class="sourceLineNo">2013</span>        else {<a name="line.2013"></a>
<span class="sourceLineNo">2014</span>            // with no buffer, we use XOR to draw the rectangle "over" the<a name="line.2014"></a>
<span class="sourceLineNo">2015</span>            // chart...<a name="line.2015"></a>
<span class="sourceLineNo">2016</span>            drawZoomRectangle(g2, true);<a name="line.2016"></a>
<span class="sourceLineNo">2017</span>        }<a name="line.2017"></a>
<span class="sourceLineNo">2018</span>        g2.dispose();<a name="line.2018"></a>
<span class="sourceLineNo">2019</span><a name="line.2019"></a>
<span class="sourceLineNo">2020</span>    }<a name="line.2020"></a>
<span class="sourceLineNo">2021</span><a name="line.2021"></a>
<span class="sourceLineNo">2022</span>    /**<a name="line.2022"></a>
<span class="sourceLineNo">2023</span>     * Handles a 'mouse released' event.  On Windows, we need to check if this<a name="line.2023"></a>
<span class="sourceLineNo">2024</span>     * is a popup trigger, but only if we haven't already been tracking a zoom<a name="line.2024"></a>
<span class="sourceLineNo">2025</span>     * rectangle.<a name="line.2025"></a>
<span class="sourceLineNo">2026</span>     *<a name="line.2026"></a>
<span class="sourceLineNo">2027</span>     * @param e  information about the event.<a name="line.2027"></a>
<span class="sourceLineNo">2028</span>     */<a name="line.2028"></a>
<span class="sourceLineNo">2029</span>    public void mouseReleased(MouseEvent e) {<a name="line.2029"></a>
<span class="sourceLineNo">2030</span><a name="line.2030"></a>
<span class="sourceLineNo">2031</span>        // if we've been panning, we need to reset now that the mouse is <a name="line.2031"></a>
<span class="sourceLineNo">2032</span>        // released...<a name="line.2032"></a>
<span class="sourceLineNo">2033</span>        if (this.panLast != null) {<a name="line.2033"></a>
<span class="sourceLineNo">2034</span>            this.panLast = null;<a name="line.2034"></a>
<span class="sourceLineNo">2035</span>            setCursor(Cursor.getDefaultCursor());<a name="line.2035"></a>
<span class="sourceLineNo">2036</span>        }<a name="line.2036"></a>
<span class="sourceLineNo">2037</span><a name="line.2037"></a>
<span class="sourceLineNo">2038</span>        else if (this.zoomRectangle != null) {<a name="line.2038"></a>
<span class="sourceLineNo">2039</span>            boolean hZoom = false;<a name="line.2039"></a>
<span class="sourceLineNo">2040</span>            boolean vZoom = false;<a name="line.2040"></a>
<span class="sourceLineNo">2041</span>            if (this.orientation == PlotOrientation.HORIZONTAL) {<a name="line.2041"></a>
<span class="sourceLineNo">2042</span>                hZoom = this.rangeZoomable;<a name="line.2042"></a>
<span class="sourceLineNo">2043</span>                vZoom = this.domainZoomable;<a name="line.2043"></a>
<span class="sourceLineNo">2044</span>            }<a name="line.2044"></a>
<span class="sourceLineNo">2045</span>            else {<a name="line.2045"></a>
<span class="sourceLineNo">2046</span>                hZoom = this.domainZoomable;<a name="line.2046"></a>
<span class="sourceLineNo">2047</span>                vZoom = this.rangeZoomable;<a name="line.2047"></a>
<span class="sourceLineNo">2048</span>            }<a name="line.2048"></a>
<span class="sourceLineNo">2049</span><a name="line.2049"></a>
<span class="sourceLineNo">2050</span>            boolean zoomTrigger1 = hZoom &amp;&amp; Math.abs(e.getX()<a name="line.2050"></a>
<span class="sourceLineNo">2051</span>                - this.zoomPoint.getX()) &gt;= this.zoomTriggerDistance;<a name="line.2051"></a>
<span class="sourceLineNo">2052</span>            boolean zoomTrigger2 = vZoom &amp;&amp; Math.abs(e.getY()<a name="line.2052"></a>
<span class="sourceLineNo">2053</span>                - this.zoomPoint.getY()) &gt;= this.zoomTriggerDistance;<a name="line.2053"></a>
<span class="sourceLineNo">2054</span>            if (zoomTrigger1 || zoomTrigger2) {<a name="line.2054"></a>
<span class="sourceLineNo">2055</span>                if ((hZoom &amp;&amp; (e.getX() &lt; this.zoomPoint.getX()))<a name="line.2055"></a>
<span class="sourceLineNo">2056</span>                    || (vZoom &amp;&amp; (e.getY() &lt; this.zoomPoint.getY()))) {<a name="line.2056"></a>
<span class="sourceLineNo">2057</span>                    restoreAutoBounds();<a name="line.2057"></a>
<span class="sourceLineNo">2058</span>                }<a name="line.2058"></a>
<span class="sourceLineNo">2059</span>                else {<a name="line.2059"></a>
<span class="sourceLineNo">2060</span>                    double x, y, w, h;<a name="line.2060"></a>
<span class="sourceLineNo">2061</span>                    Rectangle2D screenDataArea = getScreenDataArea(<a name="line.2061"></a>
<span class="sourceLineNo">2062</span>                            (int) this.zoomPoint.getX(),<a name="line.2062"></a>
<span class="sourceLineNo">2063</span>                            (int) this.zoomPoint.getY());<a name="line.2063"></a>
<span class="sourceLineNo">2064</span>                    double maxX = screenDataArea.getMaxX();<a name="line.2064"></a>
<span class="sourceLineNo">2065</span>                    double maxY = screenDataArea.getMaxY();<a name="line.2065"></a>
<span class="sourceLineNo">2066</span>                    // for mouseReleased event, (horizontalZoom || verticalZoom)<a name="line.2066"></a>
<span class="sourceLineNo">2067</span>                    // will be true, so we can just test for either being false;<a name="line.2067"></a>
<span class="sourceLineNo">2068</span>                    // otherwise both are true<a name="line.2068"></a>
<span class="sourceLineNo">2069</span>                    if (!vZoom) {<a name="line.2069"></a>
<span class="sourceLineNo">2070</span>                        x = this.zoomPoint.getX();<a name="line.2070"></a>
<span class="sourceLineNo">2071</span>                        y = screenDataArea.getMinY();<a name="line.2071"></a>
<span class="sourceLineNo">2072</span>                        w = Math.min(this.zoomRectangle.getWidth(),<a name="line.2072"></a>
<span class="sourceLineNo">2073</span>                                maxX - this.zoomPoint.getX());<a name="line.2073"></a>
<span class="sourceLineNo">2074</span>                        h = screenDataArea.getHeight();<a name="line.2074"></a>
<span class="sourceLineNo">2075</span>                    }<a name="line.2075"></a>
<span class="sourceLineNo">2076</span>                    else if (!hZoom) {<a name="line.2076"></a>
<span class="sourceLineNo">2077</span>                        x = screenDataArea.getMinX();<a name="line.2077"></a>
<span class="sourceLineNo">2078</span>                        y = this.zoomPoint.getY();<a name="line.2078"></a>
<span class="sourceLineNo">2079</span>                        w = screenDataArea.getWidth();<a name="line.2079"></a>
<span class="sourceLineNo">2080</span>                        h = Math.min(this.zoomRectangle.getHeight(),<a name="line.2080"></a>
<span class="sourceLineNo">2081</span>                                maxY - this.zoomPoint.getY());<a name="line.2081"></a>
<span class="sourceLineNo">2082</span>                    }<a name="line.2082"></a>
<span class="sourceLineNo">2083</span>                    else {<a name="line.2083"></a>
<span class="sourceLineNo">2084</span>                        x = this.zoomPoint.getX();<a name="line.2084"></a>
<span class="sourceLineNo">2085</span>                        y = this.zoomPoint.getY();<a name="line.2085"></a>
<span class="sourceLineNo">2086</span>                        w = Math.min(this.zoomRectangle.getWidth(),<a name="line.2086"></a>
<span class="sourceLineNo">2087</span>                                maxX - this.zoomPoint.getX());<a name="line.2087"></a>
<span class="sourceLineNo">2088</span>                        h = Math.min(this.zoomRectangle.getHeight(),<a name="line.2088"></a>
<span class="sourceLineNo">2089</span>                                maxY - this.zoomPoint.getY());<a name="line.2089"></a>
<span class="sourceLineNo">2090</span>                    }<a name="line.2090"></a>
<span class="sourceLineNo">2091</span>                    Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);<a name="line.2091"></a>
<span class="sourceLineNo">2092</span>                    zoom(zoomArea);<a name="line.2092"></a>
<span class="sourceLineNo">2093</span>                }<a name="line.2093"></a>
<span class="sourceLineNo">2094</span>                this.zoomPoint = null;<a name="line.2094"></a>
<span class="sourceLineNo">2095</span>                this.zoomRectangle = null;<a name="line.2095"></a>
<span class="sourceLineNo">2096</span>            }<a name="line.2096"></a>
<span class="sourceLineNo">2097</span>            else {<a name="line.2097"></a>
<span class="sourceLineNo">2098</span>                // erase the zoom rectangle<a name="line.2098"></a>
<span class="sourceLineNo">2099</span>                Graphics2D g2 = (Graphics2D) getGraphics();<a name="line.2099"></a>
<span class="sourceLineNo">2100</span>                if (this.useBuffer) {<a name="line.2100"></a>
<span class="sourceLineNo">2101</span>                    repaint();<a name="line.2101"></a>
<span class="sourceLineNo">2102</span>                }<a name="line.2102"></a>
<span class="sourceLineNo">2103</span>                else {<a name="line.2103"></a>
<span class="sourceLineNo">2104</span>                    drawZoomRectangle(g2, true);<a name="line.2104"></a>
<span class="sourceLineNo">2105</span>                }<a name="line.2105"></a>
<span class="sourceLineNo">2106</span>                g2.dispose();<a name="line.2106"></a>
<span class="sourceLineNo">2107</span>                this.zoomPoint = null;<a name="line.2107"></a>
<span class="sourceLineNo">2108</span>                this.zoomRectangle = null;<a name="line.2108"></a>
<span class="sourceLineNo">2109</span>            }<a name="line.2109"></a>
<span class="sourceLineNo">2110</span><a name="line.2110"></a>
<span class="sourceLineNo">2111</span>        }<a name="line.2111"></a>
<span class="sourceLineNo">2112</span><a name="line.2112"></a>
<span class="sourceLineNo">2113</span>        else if (e.isPopupTrigger()) {<a name="line.2113"></a>
<span class="sourceLineNo">2114</span>            if (this.popup != null) {<a name="line.2114"></a>
<span class="sourceLineNo">2115</span>                displayPopupMenu(e.getX(), e.getY());<a name="line.2115"></a>
<span class="sourceLineNo">2116</span>            }<a name="line.2116"></a>
<span class="sourceLineNo">2117</span>        }<a name="line.2117"></a>
<span class="sourceLineNo">2118</span><a name="line.2118"></a>
<span class="sourceLineNo">2119</span>    }<a name="line.2119"></a>
<span class="sourceLineNo">2120</span><a name="line.2120"></a>
<span class="sourceLineNo">2121</span>    /**<a name="line.2121"></a>
<span class="sourceLineNo">2122</span>     * Receives notification of mouse clicks on the panel. These are<a name="line.2122"></a>
<span class="sourceLineNo">2123</span>     * translated and passed on to any registered {@link ChartMouseListener}s.<a name="line.2123"></a>
<span class="sourceLineNo">2124</span>     *<a name="line.2124"></a>
<span class="sourceLineNo">2125</span>     * @param event  Information about the mouse event.<a name="line.2125"></a>
<span class="sourceLineNo">2126</span>     */<a name="line.2126"></a>
<span class="sourceLineNo">2127</span>    public void mouseClicked(MouseEvent event) {<a name="line.2127"></a>
<span class="sourceLineNo">2128</span><a name="line.2128"></a>
<span class="sourceLineNo">2129</span>        Insets insets = getInsets();<a name="line.2129"></a>
<span class="sourceLineNo">2130</span>        int x = (int) ((event.getX() - insets.left) / this.scaleX);<a name="line.2130"></a>
<span class="sourceLineNo">2131</span>        int y = (int) ((event.getY() - insets.top) / this.scaleY);<a name="line.2131"></a>
<span class="sourceLineNo">2132</span><a name="line.2132"></a>
<span class="sourceLineNo">2133</span>        this.anchor = new Point2D.Double(x, y);<a name="line.2133"></a>
<span class="sourceLineNo">2134</span>        if (this.chart == null) {<a name="line.2134"></a>
<span class="sourceLineNo">2135</span>            return;<a name="line.2135"></a>
<span class="sourceLineNo">2136</span>        }<a name="line.2136"></a>
<span class="sourceLineNo">2137</span>        this.chart.setNotify(true);  // force a redraw<a name="line.2137"></a>
<span class="sourceLineNo">2138</span>        // new entity code...<a name="line.2138"></a>
<span class="sourceLineNo">2139</span>        Object[] listeners = this.chartMouseListeners.getListeners(<a name="line.2139"></a>
<span class="sourceLineNo">2140</span>                ChartMouseListener.class);<a name="line.2140"></a>
<span class="sourceLineNo">2141</span>        if (listeners.length == 0) {<a name="line.2141"></a>
<span class="sourceLineNo">2142</span>            return;<a name="line.2142"></a>
<span class="sourceLineNo">2143</span>        }<a name="line.2143"></a>
<span class="sourceLineNo">2144</span><a name="line.2144"></a>
<span class="sourceLineNo">2145</span>        ChartEntity entity = null;<a name="line.2145"></a>
<span class="sourceLineNo">2146</span>        if (this.info != null) {<a name="line.2146"></a>
<span class="sourceLineNo">2147</span>            EntityCollection entities = this.info.getEntityCollection();<a name="line.2147"></a>
<span class="sourceLineNo">2148</span>            if (entities != null) {<a name="line.2148"></a>
<span class="sourceLineNo">2149</span>                entity = entities.getEntity(x, y);<a name="line.2149"></a>
<span class="sourceLineNo">2150</span>            }<a name="line.2150"></a>
<span class="sourceLineNo">2151</span>        }<a name="line.2151"></a>
<span class="sourceLineNo">2152</span>        ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event,<a name="line.2152"></a>
<span class="sourceLineNo">2153</span>                entity);<a name="line.2153"></a>
<span class="sourceLineNo">2154</span>        for (int i = listeners.length - 1; i &gt;= 0; i -= 1) {<a name="line.2154"></a>
<span class="sourceLineNo">2155</span>            ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent);<a name="line.2155"></a>
<span class="sourceLineNo">2156</span>        }<a name="line.2156"></a>
<span class="sourceLineNo">2157</span><a name="line.2157"></a>
<span class="sourceLineNo">2158</span>    }<a name="line.2158"></a>
<span class="sourceLineNo">2159</span><a name="line.2159"></a>
<span class="sourceLineNo">2160</span>    /**<a name="line.2160"></a>
<span class="sourceLineNo">2161</span>     * Implementation of the MouseMotionListener's method.<a name="line.2161"></a>
<span class="sourceLineNo">2162</span>     *<a name="line.2162"></a>
<span class="sourceLineNo">2163</span>     * @param e  the event.<a name="line.2163"></a>
<span class="sourceLineNo">2164</span>     */<a name="line.2164"></a>
<span class="sourceLineNo">2165</span>    public void mouseMoved(MouseEvent e) {<a name="line.2165"></a>
<span class="sourceLineNo">2166</span>        Graphics2D g2 = (Graphics2D) getGraphics();<a name="line.2166"></a>
<span class="sourceLineNo">2167</span>        if (this.horizontalAxisTrace) {<a name="line.2167"></a>
<span class="sourceLineNo">2168</span>            drawHorizontalAxisTrace(g2, e.getX());<a name="line.2168"></a>
<span class="sourceLineNo">2169</span>        }<a name="line.2169"></a>
<span class="sourceLineNo">2170</span>        if (this.verticalAxisTrace) {<a name="line.2170"></a>
<span class="sourceLineNo">2171</span>            drawVerticalAxisTrace(g2, e.getY());<a name="line.2171"></a>
<span class="sourceLineNo">2172</span>        }<a name="line.2172"></a>
<span class="sourceLineNo">2173</span>        g2.dispose();<a name="line.2173"></a>
<span class="sourceLineNo">2174</span><a name="line.2174"></a>
<span class="sourceLineNo">2175</span>        Object[] listeners = this.chartMouseListeners.getListeners(<a name="line.2175"></a>
<span class="sourceLineNo">2176</span>                ChartMouseListener.class);<a name="line.2176"></a>
<span class="sourceLineNo">2177</span>        if (listeners.length == 0) {<a name="line.2177"></a>
<span class="sourceLineNo">2178</span>            return;<a name="line.2178"></a>
<span class="sourceLineNo">2179</span>        }<a name="line.2179"></a>
<span class="sourceLineNo">2180</span>        Insets insets = getInsets();<a name="line.2180"></a>
<span class="sourceLineNo">2181</span>        int x = (int) ((e.getX() - insets.left) / this.scaleX);<a name="line.2181"></a>
<span class="sourceLineNo">2182</span>        int y = (int) ((e.getY() - insets.top) / this.scaleY);<a name="line.2182"></a>
<span class="sourceLineNo">2183</span><a name="line.2183"></a>
<span class="sourceLineNo">2184</span>        ChartEntity entity = null;<a name="line.2184"></a>
<span class="sourceLineNo">2185</span>        if (this.info != null) {<a name="line.2185"></a>
<span class="sourceLineNo">2186</span>            EntityCollection entities = this.info.getEntityCollection();<a name="line.2186"></a>
<span class="sourceLineNo">2187</span>            if (entities != null) {<a name="line.2187"></a>
<span class="sourceLineNo">2188</span>                entity = entities.getEntity(x, y);<a name="line.2188"></a>
<span class="sourceLineNo">2189</span>            }<a name="line.2189"></a>
<span class="sourceLineNo">2190</span>        }<a name="line.2190"></a>
<span class="sourceLineNo">2191</span><a name="line.2191"></a>
<span class="sourceLineNo">2192</span>        // we can only generate events if the panel's chart is not null<a name="line.2192"></a>
<span class="sourceLineNo">2193</span>        // (see bug report 1556951)<a name="line.2193"></a>
<span class="sourceLineNo">2194</span>        if (this.chart != null) {<a name="line.2194"></a>
<span class="sourceLineNo">2195</span>            ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity);<a name="line.2195"></a>
<span class="sourceLineNo">2196</span>            for (int i = listeners.length - 1; i &gt;= 0; i -= 1) {<a name="line.2196"></a>
<span class="sourceLineNo">2197</span>                ((ChartMouseListener) listeners[i]).chartMouseMoved(event);<a name="line.2197"></a>
<span class="sourceLineNo">2198</span>            }<a name="line.2198"></a>
<span class="sourceLineNo">2199</span>        }<a name="line.2199"></a>
<span class="sourceLineNo">2200</span><a name="line.2200"></a>
<span class="sourceLineNo">2201</span>    }<a name="line.2201"></a>
<span class="sourceLineNo">2202</span><a name="line.2202"></a>
<span class="sourceLineNo">2203</span>    /**<a name="line.2203"></a>
<span class="sourceLineNo">2204</span>     * Zooms in on an anchor point (specified in screen coordinate space).<a name="line.2204"></a>
<span class="sourceLineNo">2205</span>     *<a name="line.2205"></a>
<span class="sourceLineNo">2206</span>     * @param x  the x value (in screen coordinates).<a name="line.2206"></a>
<span class="sourceLineNo">2207</span>     * @param y  the y value (in screen coordinates).<a name="line.2207"></a>
<span class="sourceLineNo">2208</span>     */<a name="line.2208"></a>
<span class="sourceLineNo">2209</span>    public void zoomInBoth(double x, double y) {<a name="line.2209"></a>
<span class="sourceLineNo">2210</span>        Plot plot = this.chart.getPlot();<a name="line.2210"></a>
<span class="sourceLineNo">2211</span>        if (plot == null) {<a name="line.2211"></a>
<span class="sourceLineNo">2212</span>            return;<a name="line.2212"></a>
<span class="sourceLineNo">2213</span>        }<a name="line.2213"></a>
<span class="sourceLineNo">2214</span>        // here we tweak the notify flag on the plot so that only<a name="line.2214"></a>
<span class="sourceLineNo">2215</span>        // one notification happens even though we update multiple<a name="line.2215"></a>
<span class="sourceLineNo">2216</span>        // axes...<a name="line.2216"></a>
<span class="sourceLineNo">2217</span>        boolean savedNotify = plot.isNotify();<a name="line.2217"></a>
<span class="sourceLineNo">2218</span>        plot.setNotify(false);<a name="line.2218"></a>
<span class="sourceLineNo">2219</span>        zoomInDomain(x, y);<a name="line.2219"></a>
<span class="sourceLineNo">2220</span>        zoomInRange(x, y);<a name="line.2220"></a>
<span class="sourceLineNo">2221</span>        plot.setNotify(savedNotify);<a name="line.2221"></a>
<span class="sourceLineNo">2222</span>    }<a name="line.2222"></a>
<span class="sourceLineNo">2223</span><a name="line.2223"></a>
<span class="sourceLineNo">2224</span>    /**<a name="line.2224"></a>
<span class="sourceLineNo">2225</span>     * Decreases the length of the domain axis, centered about the given<a name="line.2225"></a>
<span class="sourceLineNo">2226</span>     * coordinate on the screen.  The length of the domain axis is reduced<a name="line.2226"></a>
<span class="sourceLineNo">2227</span>     * by the value of {@link #getZoomInFactor()}.<a name="line.2227"></a>
<span class="sourceLineNo">2228</span>     *<a name="line.2228"></a>
<span class="sourceLineNo">2229</span>     * @param x  the x coordinate (in screen coordinates).<a name="line.2229"></a>
<span class="sourceLineNo">2230</span>     * @param y  the y-coordinate (in screen coordinates).<a name="line.2230"></a>
<span class="sourceLineNo">2231</span>     */<a name="line.2231"></a>
<span class="sourceLineNo">2232</span>    public void zoomInDomain(double x, double y) {<a name="line.2232"></a>
<span class="sourceLineNo">2233</span>        Plot plot = this.chart.getPlot();<a name="line.2233"></a>
<span class="sourceLineNo">2234</span>        if (plot instanceof Zoomable) {<a name="line.2234"></a>
<span class="sourceLineNo">2235</span>            // here we tweak the notify flag on the plot so that only<a name="line.2235"></a>
<span class="sourceLineNo">2236</span>            // one notification happens even though we update multiple<a name="line.2236"></a>
<span class="sourceLineNo">2237</span>            // axes...<a name="line.2237"></a>
<span class="sourceLineNo">2238</span>            boolean savedNotify = plot.isNotify();<a name="line.2238"></a>
<span class="sourceLineNo">2239</span>            plot.setNotify(false);<a name="line.2239"></a>
<span class="sourceLineNo">2240</span>            Zoomable z = (Zoomable) plot;<a name="line.2240"></a>
<span class="sourceLineNo">2241</span>            z.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(),<a name="line.2241"></a>
<span class="sourceLineNo">2242</span>                    translateScreenToJava2D(new Point((int) x, (int) y)),<a name="line.2242"></a>
<span class="sourceLineNo">2243</span>                    this.zoomAroundAnchor);<a name="line.2243"></a>
<span class="sourceLineNo">2244</span>            plot.setNotify(savedNotify);<a name="line.2244"></a>
<span class="sourceLineNo">2245</span>        }<a name="line.2245"></a>
<span class="sourceLineNo">2246</span>    }<a name="line.2246"></a>
<span class="sourceLineNo">2247</span><a name="line.2247"></a>
<span class="sourceLineNo">2248</span>    /**<a name="line.2248"></a>
<span class="sourceLineNo">2249</span>     * Decreases the length of the range axis, centered about the given<a name="line.2249"></a>
<span class="sourceLineNo">2250</span>     * coordinate on the screen.  The length of the range axis is reduced by<a name="line.2250"></a>
<span class="sourceLineNo">2251</span>     * the value of {@link #getZoomInFactor()}.<a name="line.2251"></a>
<span class="sourceLineNo">2252</span>     *<a name="line.2252"></a>
<span class="sourceLineNo">2253</span>     * @param x  the x-coordinate (in screen coordinates).<a name="line.2253"></a>
<span class="sourceLineNo">2254</span>     * @param y  the y coordinate (in screen coordinates).<a name="line.2254"></a>
<span class="sourceLineNo">2255</span>     */<a name="line.2255"></a>
<span class="sourceLineNo">2256</span>    public void zoomInRange(double x, double y) {<a name="line.2256"></a>
<span class="sourceLineNo">2257</span>        Plot plot = this.chart.getPlot();<a name="line.2257"></a>
<span class="sourceLineNo">2258</span>        if (plot instanceof Zoomable) {<a name="line.2258"></a>
<span class="sourceLineNo">2259</span>            // here we tweak the notify flag on the plot so that only<a name="line.2259"></a>
<span class="sourceLineNo">2260</span>            // one notification happens even though we update multiple<a name="line.2260"></a>
<span class="sourceLineNo">2261</span>            // axes...<a name="line.2261"></a>
<span class="sourceLineNo">2262</span>            boolean savedNotify = plot.isNotify();<a name="line.2262"></a>
<span class="sourceLineNo">2263</span>            plot.setNotify(false);<a name="line.2263"></a>
<span class="sourceLineNo">2264</span>            Zoomable z = (Zoomable) plot;<a name="line.2264"></a>
<span class="sourceLineNo">2265</span>            z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(),<a name="line.2265"></a>
<span class="sourceLineNo">2266</span>                    translateScreenToJava2D(new Point((int) x, (int) y)),<a name="line.2266"></a>
<span class="sourceLineNo">2267</span>                    this.zoomAroundAnchor);<a name="line.2267"></a>
<span class="sourceLineNo">2268</span>            plot.setNotify(savedNotify);<a name="line.2268"></a>
<span class="sourceLineNo">2269</span>        }<a name="line.2269"></a>
<span class="sourceLineNo">2270</span>    }<a name="line.2270"></a>
<span class="sourceLineNo">2271</span><a name="line.2271"></a>
<span class="sourceLineNo">2272</span>    /**<a name="line.2272"></a>
<span class="sourceLineNo">2273</span>     * Zooms out on an anchor point (specified in screen coordinate space).<a name="line.2273"></a>
<span class="sourceLineNo">2274</span>     *<a name="line.2274"></a>
<span class="sourceLineNo">2275</span>     * @param x  the x value (in screen coordinates).<a name="line.2275"></a>
<span class="sourceLineNo">2276</span>     * @param y  the y value (in screen coordinates).<a name="line.2276"></a>
<span class="sourceLineNo">2277</span>     */<a name="line.2277"></a>
<span class="sourceLineNo">2278</span>    public void zoomOutBoth(double x, double y) {<a name="line.2278"></a>
<span class="sourceLineNo">2279</span>        Plot plot = this.chart.getPlot();<a name="line.2279"></a>
<span class="sourceLineNo">2280</span>        if (plot == null) {<a name="line.2280"></a>
<span class="sourceLineNo">2281</span>            return;<a name="line.2281"></a>
<span class="sourceLineNo">2282</span>        }<a name="line.2282"></a>
<span class="sourceLineNo">2283</span>        // here we tweak the notify flag on the plot so that only<a name="line.2283"></a>
<span class="sourceLineNo">2284</span>        // one notification happens even though we update multiple<a name="line.2284"></a>
<span class="sourceLineNo">2285</span>        // axes...<a name="line.2285"></a>
<span class="sourceLineNo">2286</span>        boolean savedNotify = plot.isNotify();<a name="line.2286"></a>
<span class="sourceLineNo">2287</span>        plot.setNotify(false);<a name="line.2287"></a>
<span class="sourceLineNo">2288</span>        zoomOutDomain(x, y);<a name="line.2288"></a>
<span class="sourceLineNo">2289</span>        zoomOutRange(x, y);<a name="line.2289"></a>
<span class="sourceLineNo">2290</span>        plot.setNotify(savedNotify);<a name="line.2290"></a>
<span class="sourceLineNo">2291</span>    }<a name="line.2291"></a>
<span class="sourceLineNo">2292</span><a name="line.2292"></a>
<span class="sourceLineNo">2293</span>    /**<a name="line.2293"></a>
<span class="sourceLineNo">2294</span>     * Increases the length of the domain axis, centered about the given<a name="line.2294"></a>
<span class="sourceLineNo">2295</span>     * coordinate on the screen.  The length of the domain axis is increased<a name="line.2295"></a>
<span class="sourceLineNo">2296</span>     * by the value of {@link #getZoomOutFactor()}.<a name="line.2296"></a>
<span class="sourceLineNo">2297</span>     *<a name="line.2297"></a>
<span class="sourceLineNo">2298</span>     * @param x  the x coordinate (in screen coordinates).<a name="line.2298"></a>
<span class="sourceLineNo">2299</span>     * @param y  the y-coordinate (in screen coordinates).<a name="line.2299"></a>
<span class="sourceLineNo">2300</span>     */<a name="line.2300"></a>
<span class="sourceLineNo">2301</span>    public void zoomOutDomain(double x, double y) {<a name="line.2301"></a>
<span class="sourceLineNo">2302</span>        Plot plot = this.chart.getPlot();<a name="line.2302"></a>
<span class="sourceLineNo">2303</span>        if (plot instanceof Zoomable) {<a name="line.2303"></a>
<span class="sourceLineNo">2304</span>            // here we tweak the notify flag on the plot so that only<a name="line.2304"></a>
<span class="sourceLineNo">2305</span>            // one notification happens even though we update multiple<a name="line.2305"></a>
<span class="sourceLineNo">2306</span>            // axes...<a name="line.2306"></a>
<span class="sourceLineNo">2307</span>            boolean savedNotify = plot.isNotify();<a name="line.2307"></a>
<span class="sourceLineNo">2308</span>            plot.setNotify(false);<a name="line.2308"></a>
<span class="sourceLineNo">2309</span>            Zoomable z = (Zoomable) plot;<a name="line.2309"></a>
<span class="sourceLineNo">2310</span>            z.zoomDomainAxes(this.zoomOutFactor, this.info.getPlotInfo(),<a name="line.2310"></a>
<span class="sourceLineNo">2311</span>                    translateScreenToJava2D(new Point((int) x, (int) y)),<a name="line.2311"></a>
<span class="sourceLineNo">2312</span>                    this.zoomAroundAnchor);<a name="line.2312"></a>
<span class="sourceLineNo">2313</span>            plot.setNotify(savedNotify);<a name="line.2313"></a>
<span class="sourceLineNo">2314</span>        }<a name="line.2314"></a>
<span class="sourceLineNo">2315</span>    }<a name="line.2315"></a>
<span class="sourceLineNo">2316</span><a name="line.2316"></a>
<span class="sourceLineNo">2317</span>    /**<a name="line.2317"></a>
<span class="sourceLineNo">2318</span>     * Increases the length the range axis, centered about the given<a name="line.2318"></a>
<span class="sourceLineNo">2319</span>     * coordinate on the screen.  The length of the range axis is increased<a name="line.2319"></a>
<span class="sourceLineNo">2320</span>     * by the value of {@link #getZoomOutFactor()}.<a name="line.2320"></a>
<span class="sourceLineNo">2321</span>     *<a name="line.2321"></a>
<span class="sourceLineNo">2322</span>     * @param x  the x coordinate (in screen coordinates).<a name="line.2322"></a>
<span class="sourceLineNo">2323</span>     * @param y  the y-coordinate (in screen coordinates).<a name="line.2323"></a>
<span class="sourceLineNo">2324</span>     */<a name="line.2324"></a>
<span class="sourceLineNo">2325</span>    public void zoomOutRange(double x, double y) {<a name="line.2325"></a>
<span class="sourceLineNo">2326</span>        Plot plot = this.chart.getPlot();<a name="line.2326"></a>
<span class="sourceLineNo">2327</span>        if (plot instanceof Zoomable) {<a name="line.2327"></a>
<span class="sourceLineNo">2328</span>            // here we tweak the notify flag on the plot so that only<a name="line.2328"></a>
<span class="sourceLineNo">2329</span>            // one notification happens even though we update multiple<a name="line.2329"></a>
<span class="sourceLineNo">2330</span>            // axes...<a name="line.2330"></a>
<span class="sourceLineNo">2331</span>            boolean savedNotify = plot.isNotify();<a name="line.2331"></a>
<span class="sourceLineNo">2332</span>            plot.setNotify(false);<a name="line.2332"></a>
<span class="sourceLineNo">2333</span>            Zoomable z = (Zoomable) plot;<a name="line.2333"></a>
<span class="sourceLineNo">2334</span>            z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(),<a name="line.2334"></a>
<span class="sourceLineNo">2335</span>                    translateScreenToJava2D(new Point((int) x, (int) y)),<a name="line.2335"></a>
<span class="sourceLineNo">2336</span>                    this.zoomAroundAnchor);<a name="line.2336"></a>
<span class="sourceLineNo">2337</span>            plot.setNotify(savedNotify);<a name="line.2337"></a>
<span class="sourceLineNo">2338</span>        }<a name="line.2338"></a>
<span class="sourceLineNo">2339</span>    }<a name="line.2339"></a>
<span class="sourceLineNo">2340</span><a name="line.2340"></a>
<span class="sourceLineNo">2341</span>    /**<a name="line.2341"></a>
<span class="sourceLineNo">2342</span>     * Zooms in on a selected region.<a name="line.2342"></a>
<span class="sourceLineNo">2343</span>     *<a name="line.2343"></a>
<span class="sourceLineNo">2344</span>     * @param selection  the selected region.<a name="line.2344"></a>
<span class="sourceLineNo">2345</span>     */<a name="line.2345"></a>
<span class="sourceLineNo">2346</span>    public void zoom(Rectangle2D selection) {<a name="line.2346"></a>
<span class="sourceLineNo">2347</span><a name="line.2347"></a>
<span class="sourceLineNo">2348</span>        // get the origin of the zoom selection in the Java2D space used for<a name="line.2348"></a>
<span class="sourceLineNo">2349</span>        // drawing the chart (that is, before any scaling to fit the panel)<a name="line.2349"></a>
<span class="sourceLineNo">2350</span>        Point2D selectOrigin = translateScreenToJava2D(new Point(<a name="line.2350"></a>
<span class="sourceLineNo">2351</span>                (int) Math.ceil(selection.getX()),<a name="line.2351"></a>
<span class="sourceLineNo">2352</span>                (int) Math.ceil(selection.getY())));<a name="line.2352"></a>
<span class="sourceLineNo">2353</span>        PlotRenderingInfo plotInfo = this.info.getPlotInfo();<a name="line.2353"></a>
<span class="sourceLineNo">2354</span>        Rectangle2D scaledDataArea = getScreenDataArea(<a name="line.2354"></a>
<span class="sourceLineNo">2355</span>                (int) selection.getCenterX(), (int) selection.getCenterY());<a name="line.2355"></a>
<span class="sourceLineNo">2356</span>        if ((selection.getHeight() &gt; 0) &amp;&amp; (selection.getWidth() &gt; 0)) {<a name="line.2356"></a>
<span class="sourceLineNo">2357</span><a name="line.2357"></a>
<span class="sourceLineNo">2358</span>            double hLower = (selection.getMinX() - scaledDataArea.getMinX())<a name="line.2358"></a>
<span class="sourceLineNo">2359</span>                / scaledDataArea.getWidth();<a name="line.2359"></a>
<span class="sourceLineNo">2360</span>            double hUpper = (selection.getMaxX() - scaledDataArea.getMinX())<a name="line.2360"></a>
<span class="sourceLineNo">2361</span>                / scaledDataArea.getWidth();<a name="line.2361"></a>
<span class="sourceLineNo">2362</span>            double vLower = (scaledDataArea.getMaxY() - selection.getMaxY())<a name="line.2362"></a>
<span class="sourceLineNo">2363</span>                / scaledDataArea.getHeight();<a name="line.2363"></a>
<span class="sourceLineNo">2364</span>            double vUpper = (scaledDataArea.getMaxY() - selection.getMinY())<a name="line.2364"></a>
<span class="sourceLineNo">2365</span>                / scaledDataArea.getHeight();<a name="line.2365"></a>
<span class="sourceLineNo">2366</span><a name="line.2366"></a>
<span class="sourceLineNo">2367</span>            Plot p = this.chart.getPlot();<a name="line.2367"></a>
<span class="sourceLineNo">2368</span>            if (p instanceof Zoomable) {<a name="line.2368"></a>
<span class="sourceLineNo">2369</span>                // here we tweak the notify flag on the plot so that only<a name="line.2369"></a>
<span class="sourceLineNo">2370</span>                // one notification happens even though we update multiple<a name="line.2370"></a>
<span class="sourceLineNo">2371</span>                // axes...<a name="line.2371"></a>
<span class="sourceLineNo">2372</span>                boolean savedNotify = p.isNotify();<a name="line.2372"></a>
<span class="sourceLineNo">2373</span>                p.setNotify(false);<a name="line.2373"></a>
<span class="sourceLineNo">2374</span>                Zoomable z = (Zoomable) p;<a name="line.2374"></a>
<span class="sourceLineNo">2375</span>                if (z.getOrientation() == PlotOrientation.HORIZONTAL) {<a name="line.2375"></a>
<span class="sourceLineNo">2376</span>                    z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin);<a name="line.2376"></a>
<span class="sourceLineNo">2377</span>                    z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin);<a name="line.2377"></a>
<span class="sourceLineNo">2378</span>                }<a name="line.2378"></a>
<span class="sourceLineNo">2379</span>                else {<a name="line.2379"></a>
<span class="sourceLineNo">2380</span>                    z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin);<a name="line.2380"></a>
<span class="sourceLineNo">2381</span>                    z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin);<a name="line.2381"></a>
<span class="sourceLineNo">2382</span>                }<a name="line.2382"></a>
<span class="sourceLineNo">2383</span>                p.setNotify(savedNotify);<a name="line.2383"></a>
<span class="sourceLineNo">2384</span>            }<a name="line.2384"></a>
<span class="sourceLineNo">2385</span><a name="line.2385"></a>
<span class="sourceLineNo">2386</span>        }<a name="line.2386"></a>
<span class="sourceLineNo">2387</span><a name="line.2387"></a>
<span class="sourceLineNo">2388</span>    }<a name="line.2388"></a>
<span class="sourceLineNo">2389</span><a name="line.2389"></a>
<span class="sourceLineNo">2390</span>    /**<a name="line.2390"></a>
<span class="sourceLineNo">2391</span>     * Restores the auto-range calculation on both axes.<a name="line.2391"></a>
<span class="sourceLineNo">2392</span>     */<a name="line.2392"></a>
<span class="sourceLineNo">2393</span>    public void restoreAutoBounds() {<a name="line.2393"></a>
<span class="sourceLineNo">2394</span>        Plot plot = this.chart.getPlot();<a name="line.2394"></a>
<span class="sourceLineNo">2395</span>        if (plot == null) {<a name="line.2395"></a>
<span class="sourceLineNo">2396</span>            return;<a name="line.2396"></a>
<span class="sourceLineNo">2397</span>        }<a name="line.2397"></a>
<span class="sourceLineNo">2398</span>        // here we tweak the notify flag on the plot so that only<a name="line.2398"></a>
<span class="sourceLineNo">2399</span>        // one notification happens even though we update multiple<a name="line.2399"></a>
<span class="sourceLineNo">2400</span>        // axes...<a name="line.2400"></a>
<span class="sourceLineNo">2401</span>        boolean savedNotify = plot.isNotify();<a name="line.2401"></a>
<span class="sourceLineNo">2402</span>        plot.setNotify(false);<a name="line.2402"></a>
<span class="sourceLineNo">2403</span>        restoreAutoDomainBounds();<a name="line.2403"></a>
<span class="sourceLineNo">2404</span>        restoreAutoRangeBounds();<a name="line.2404"></a>
<span class="sourceLineNo">2405</span>        plot.setNotify(savedNotify);<a name="line.2405"></a>
<span class="sourceLineNo">2406</span>    }<a name="line.2406"></a>
<span class="sourceLineNo">2407</span><a name="line.2407"></a>
<span class="sourceLineNo">2408</span>    /**<a name="line.2408"></a>
<span class="sourceLineNo">2409</span>     * Restores the auto-range calculation on the domain axis.<a name="line.2409"></a>
<span class="sourceLineNo">2410</span>     */<a name="line.2410"></a>
<span class="sourceLineNo">2411</span>    public void restoreAutoDomainBounds() {<a name="line.2411"></a>
<span class="sourceLineNo">2412</span>        Plot plot = this.chart.getPlot();<a name="line.2412"></a>
<span class="sourceLineNo">2413</span>        if (plot instanceof Zoomable) {<a name="line.2413"></a>
<span class="sourceLineNo">2414</span>            Zoomable z = (Zoomable) plot;<a name="line.2414"></a>
<span class="sourceLineNo">2415</span>            // here we tweak the notify flag on the plot so that only<a name="line.2415"></a>
<span class="sourceLineNo">2416</span>            // one notification happens even though we update multiple<a name="line.2416"></a>
<span class="sourceLineNo">2417</span>            // axes...<a name="line.2417"></a>
<span class="sourceLineNo">2418</span>            boolean savedNotify = plot.isNotify();<a name="line.2418"></a>
<span class="sourceLineNo">2419</span>            plot.setNotify(false);<a name="line.2419"></a>
<span class="sourceLineNo">2420</span>            // we need to guard against this.zoomPoint being null<a name="line.2420"></a>
<span class="sourceLineNo">2421</span>            Point2D zp = (this.zoomPoint != null<a name="line.2421"></a>
<span class="sourceLineNo">2422</span>                    ? this.zoomPoint : new Point());<a name="line.2422"></a>
<span class="sourceLineNo">2423</span>            z.zoomDomainAxes(0.0, this.info.getPlotInfo(), zp);<a name="line.2423"></a>
<span class="sourceLineNo">2424</span>            plot.setNotify(savedNotify);<a name="line.2424"></a>
<span class="sourceLineNo">2425</span>        }<a name="line.2425"></a>
<span class="sourceLineNo">2426</span>    }<a name="line.2426"></a>
<span class="sourceLineNo">2427</span><a name="line.2427"></a>
<span class="sourceLineNo">2428</span>    /**<a name="line.2428"></a>
<span class="sourceLineNo">2429</span>     * Restores the auto-range calculation on the range axis.<a name="line.2429"></a>
<span class="sourceLineNo">2430</span>     */<a name="line.2430"></a>
<span class="sourceLineNo">2431</span>    public void restoreAutoRangeBounds() {<a name="line.2431"></a>
<span class="sourceLineNo">2432</span>        Plot plot = this.chart.getPlot();<a name="line.2432"></a>
<span class="sourceLineNo">2433</span>        if (plot instanceof Zoomable) {<a name="line.2433"></a>
<span class="sourceLineNo">2434</span>            Zoomable z = (Zoomable) plot;<a name="line.2434"></a>
<span class="sourceLineNo">2435</span>            // here we tweak the notify flag on the plot so that only<a name="line.2435"></a>
<span class="sourceLineNo">2436</span>            // one notification happens even though we update multiple<a name="line.2436"></a>
<span class="sourceLineNo">2437</span>            // axes...<a name="line.2437"></a>
<span class="sourceLineNo">2438</span>            boolean savedNotify = plot.isNotify();<a name="line.2438"></a>
<span class="sourceLineNo">2439</span>            plot.setNotify(false);<a name="line.2439"></a>
<span class="sourceLineNo">2440</span>            // we need to guard against this.zoomPoint being null<a name="line.2440"></a>
<span class="sourceLineNo">2441</span>            Point2D zp = (this.zoomPoint != null<a name="line.2441"></a>
<span class="sourceLineNo">2442</span>                    ? this.zoomPoint : new Point());<a name="line.2442"></a>
<span class="sourceLineNo">2443</span>            z.zoomRangeAxes(0.0, this.info.getPlotInfo(), zp);<a name="line.2443"></a>
<span class="sourceLineNo">2444</span>            plot.setNotify(savedNotify);<a name="line.2444"></a>
<span class="sourceLineNo">2445</span>        }<a name="line.2445"></a>
<span class="sourceLineNo">2446</span>    }<a name="line.2446"></a>
<span class="sourceLineNo">2447</span><a name="line.2447"></a>
<span class="sourceLineNo">2448</span>    /**<a name="line.2448"></a>
<span class="sourceLineNo">2449</span>     * Returns the data area for the chart (the area inside the axes) with the<a name="line.2449"></a>
<span class="sourceLineNo">2450</span>     * current scaling applied (that is, the area as it appears on screen).<a name="line.2450"></a>
<span class="sourceLineNo">2451</span>     *<a name="line.2451"></a>
<span class="sourceLineNo">2452</span>     * @return The scaled data area.<a name="line.2452"></a>
<span class="sourceLineNo">2453</span>     */<a name="line.2453"></a>
<span class="sourceLineNo">2454</span>    public Rectangle2D getScreenDataArea() {<a name="line.2454"></a>
<span class="sourceLineNo">2455</span>        Rectangle2D dataArea = this.info.getPlotInfo().getDataArea();<a name="line.2455"></a>
<span class="sourceLineNo">2456</span>        Insets insets = getInsets();<a name="line.2456"></a>
<span class="sourceLineNo">2457</span>        double x = dataArea.getX() * this.scaleX + insets.left;<a name="line.2457"></a>
<span class="sourceLineNo">2458</span>        double y = dataArea.getY() * this.scaleY + insets.top;<a name="line.2458"></a>
<span class="sourceLineNo">2459</span>        double w = dataArea.getWidth() * this.scaleX;<a name="line.2459"></a>
<span class="sourceLineNo">2460</span>        double h = dataArea.getHeight() * this.scaleY;<a name="line.2460"></a>
<span class="sourceLineNo">2461</span>        return new Rectangle2D.Double(x, y, w, h);<a name="line.2461"></a>
<span class="sourceLineNo">2462</span>    }<a name="line.2462"></a>
<span class="sourceLineNo">2463</span><a name="line.2463"></a>
<span class="sourceLineNo">2464</span>    /**<a name="line.2464"></a>
<span class="sourceLineNo">2465</span>     * Returns the data area (the area inside the axes) for the plot or subplot,<a name="line.2465"></a>
<span class="sourceLineNo">2466</span>     * with the current scaling applied.<a name="line.2466"></a>
<span class="sourceLineNo">2467</span>     *<a name="line.2467"></a>
<span class="sourceLineNo">2468</span>     * @param x  the x-coordinate (for subplot selection).<a name="line.2468"></a>
<span class="sourceLineNo">2469</span>     * @param y  the y-coordinate (for subplot selection).<a name="line.2469"></a>
<span class="sourceLineNo">2470</span>     *<a name="line.2470"></a>
<span class="sourceLineNo">2471</span>     * @return The scaled data area.<a name="line.2471"></a>
<span class="sourceLineNo">2472</span>     */<a name="line.2472"></a>
<span class="sourceLineNo">2473</span>    public Rectangle2D getScreenDataArea(int x, int y) {<a name="line.2473"></a>
<span class="sourceLineNo">2474</span>        PlotRenderingInfo plotInfo = this.info.getPlotInfo();<a name="line.2474"></a>
<span class="sourceLineNo">2475</span>        Rectangle2D result;<a name="line.2475"></a>
<span class="sourceLineNo">2476</span>        if (plotInfo.getSubplotCount() == 0) {<a name="line.2476"></a>
<span class="sourceLineNo">2477</span>            result = getScreenDataArea();<a name="line.2477"></a>
<span class="sourceLineNo">2478</span>        }<a name="line.2478"></a>
<span class="sourceLineNo">2479</span>        else {<a name="line.2479"></a>
<span class="sourceLineNo">2480</span>            // get the origin of the zoom selection in the Java2D space used for<a name="line.2480"></a>
<span class="sourceLineNo">2481</span>            // drawing the chart (that is, before any scaling to fit the panel)<a name="line.2481"></a>
<span class="sourceLineNo">2482</span>            Point2D selectOrigin = translateScreenToJava2D(new Point(x, y));<a name="line.2482"></a>
<span class="sourceLineNo">2483</span>            int subplotIndex = plotInfo.getSubplotIndex(selectOrigin);<a name="line.2483"></a>
<span class="sourceLineNo">2484</span>            if (subplotIndex == -1) {<a name="line.2484"></a>
<span class="sourceLineNo">2485</span>                return null;<a name="line.2485"></a>
<span class="sourceLineNo">2486</span>            }<a name="line.2486"></a>
<span class="sourceLineNo">2487</span>            result = scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea());<a name="line.2487"></a>
<span class="sourceLineNo">2488</span>        }<a name="line.2488"></a>
<span class="sourceLineNo">2489</span>        return result;<a name="line.2489"></a>
<span class="sourceLineNo">2490</span>    }<a name="line.2490"></a>
<span class="sourceLineNo">2491</span><a name="line.2491"></a>
<span class="sourceLineNo">2492</span>    /**<a name="line.2492"></a>
<span class="sourceLineNo">2493</span>     * Returns the initial tooltip delay value used inside this chart panel.<a name="line.2493"></a>
<span class="sourceLineNo">2494</span>     *<a name="line.2494"></a>
<span class="sourceLineNo">2495</span>     * @return An integer representing the initial delay value, in milliseconds.<a name="line.2495"></a>
<span class="sourceLineNo">2496</span>     *<a name="line.2496"></a>
<span class="sourceLineNo">2497</span>     * @see javax.swing.ToolTipManager#getInitialDelay()<a name="line.2497"></a>
<span class="sourceLineNo">2498</span>     */<a name="line.2498"></a>
<span class="sourceLineNo">2499</span>    public int getInitialDelay() {<a name="line.2499"></a>
<span class="sourceLineNo">2500</span>        return this.ownToolTipInitialDelay;<a name="line.2500"></a>
<span class="sourceLineNo">2501</span>    }<a name="line.2501"></a>
<span class="sourceLineNo">2502</span><a name="line.2502"></a>
<span class="sourceLineNo">2503</span>    /**<a name="line.2503"></a>
<span class="sourceLineNo">2504</span>     * Returns the reshow tooltip delay value used inside this chart panel.<a name="line.2504"></a>
<span class="sourceLineNo">2505</span>     *<a name="line.2505"></a>
<span class="sourceLineNo">2506</span>     * @return An integer representing the reshow  delay value, in milliseconds.<a name="line.2506"></a>
<span class="sourceLineNo">2507</span>     *<a name="line.2507"></a>
<span class="sourceLineNo">2508</span>     * @see javax.swing.ToolTipManager#getReshowDelay()<a name="line.2508"></a>
<span class="sourceLineNo">2509</span>     */<a name="line.2509"></a>
<span class="sourceLineNo">2510</span>    public int getReshowDelay() {<a name="line.2510"></a>
<span class="sourceLineNo">2511</span>        return this.ownToolTipReshowDelay;<a name="line.2511"></a>
<span class="sourceLineNo">2512</span>    }<a name="line.2512"></a>
<span class="sourceLineNo">2513</span><a name="line.2513"></a>
<span class="sourceLineNo">2514</span>    /**<a name="line.2514"></a>
<span class="sourceLineNo">2515</span>     * Returns the dismissal tooltip delay value used inside this chart panel.<a name="line.2515"></a>
<span class="sourceLineNo">2516</span>     *<a name="line.2516"></a>
<span class="sourceLineNo">2517</span>     * @return An integer representing the dismissal delay value, in<a name="line.2517"></a>
<span class="sourceLineNo">2518</span>     *         milliseconds.<a name="line.2518"></a>
<span class="sourceLineNo">2519</span>     *<a name="line.2519"></a>
<span class="sourceLineNo">2520</span>     * @see javax.swing.ToolTipManager#getDismissDelay()<a name="line.2520"></a>
<span class="sourceLineNo">2521</span>     */<a name="line.2521"></a>
<span class="sourceLineNo">2522</span>    public int getDismissDelay() {<a name="line.2522"></a>
<span class="sourceLineNo">2523</span>        return this.ownToolTipDismissDelay;<a name="line.2523"></a>
<span class="sourceLineNo">2524</span>    }<a name="line.2524"></a>
<span class="sourceLineNo">2525</span><a name="line.2525"></a>
<span class="sourceLineNo">2526</span>    /**<a name="line.2526"></a>
<span class="sourceLineNo">2527</span>     * Specifies the initial delay value for this chart panel.<a name="line.2527"></a>
<span class="sourceLineNo">2528</span>     *<a name="line.2528"></a>
<span class="sourceLineNo">2529</span>     * @param delay  the number of milliseconds to delay (after the cursor has<a name="line.2529"></a>
<span class="sourceLineNo">2530</span>     *               paused) before displaying.<a name="line.2530"></a>
<span class="sourceLineNo">2531</span>     *<a name="line.2531"></a>
<span class="sourceLineNo">2532</span>     * @see javax.swing.ToolTipManager#setInitialDelay(int)<a name="line.2532"></a>
<span class="sourceLineNo">2533</span>     */<a name="line.2533"></a>
<span class="sourceLineNo">2534</span>    public void setInitialDelay(int delay) {<a name="line.2534"></a>
<span class="sourceLineNo">2535</span>        this.ownToolTipInitialDelay = delay;<a name="line.2535"></a>
<span class="sourceLineNo">2536</span>    }<a name="line.2536"></a>
<span class="sourceLineNo">2537</span><a name="line.2537"></a>
<span class="sourceLineNo">2538</span>    /**<a name="line.2538"></a>
<span class="sourceLineNo">2539</span>     * Specifies the amount of time before the user has to wait initialDelay<a name="line.2539"></a>
<span class="sourceLineNo">2540</span>     * milliseconds before a tooltip will be shown.<a name="line.2540"></a>
<span class="sourceLineNo">2541</span>     *<a name="line.2541"></a>
<span class="sourceLineNo">2542</span>     * @param delay  time in milliseconds<a name="line.2542"></a>
<span class="sourceLineNo">2543</span>     *<a name="line.2543"></a>
<span class="sourceLineNo">2544</span>     * @see javax.swing.ToolTipManager#setReshowDelay(int)<a name="line.2544"></a>
<span class="sourceLineNo">2545</span>     */<a name="line.2545"></a>
<span class="sourceLineNo">2546</span>    public void setReshowDelay(int delay) {<a name="line.2546"></a>
<span class="sourceLineNo">2547</span>        this.ownToolTipReshowDelay = delay;<a name="line.2547"></a>
<span class="sourceLineNo">2548</span>    }<a name="line.2548"></a>
<span class="sourceLineNo">2549</span><a name="line.2549"></a>
<span class="sourceLineNo">2550</span>    /**<a name="line.2550"></a>
<span class="sourceLineNo">2551</span>     * Specifies the dismissal delay value for this chart panel.<a name="line.2551"></a>
<span class="sourceLineNo">2552</span>     *<a name="line.2552"></a>
<span class="sourceLineNo">2553</span>     * @param delay the number of milliseconds to delay before taking away the<a name="line.2553"></a>
<span class="sourceLineNo">2554</span>     *              tooltip<a name="line.2554"></a>
<span class="sourceLineNo">2555</span>     *<a name="line.2555"></a>
<span class="sourceLineNo">2556</span>     * @see javax.swing.ToolTipManager#setDismissDelay(int)<a name="line.2556"></a>
<span class="sourceLineNo">2557</span>     */<a name="line.2557"></a>
<span class="sourceLineNo">2558</span>    public void setDismissDelay(int delay) {<a name="line.2558"></a>
<span class="sourceLineNo">2559</span>        this.ownToolTipDismissDelay = delay;<a name="line.2559"></a>
<span class="sourceLineNo">2560</span>    }<a name="line.2560"></a>
<span class="sourceLineNo">2561</span><a name="line.2561"></a>
<span class="sourceLineNo">2562</span>    /**<a name="line.2562"></a>
<span class="sourceLineNo">2563</span>     * Returns the zoom in factor.<a name="line.2563"></a>
<span class="sourceLineNo">2564</span>     *<a name="line.2564"></a>
<span class="sourceLineNo">2565</span>     * @return The zoom in factor.<a name="line.2565"></a>
<span class="sourceLineNo">2566</span>     *<a name="line.2566"></a>
<span class="sourceLineNo">2567</span>     * @see #setZoomInFactor(double)<a name="line.2567"></a>
<span class="sourceLineNo">2568</span>     */<a name="line.2568"></a>
<span class="sourceLineNo">2569</span>    public double getZoomInFactor() {<a name="line.2569"></a>
<span class="sourceLineNo">2570</span>        return this.zoomInFactor;<a name="line.2570"></a>
<span class="sourceLineNo">2571</span>    }<a name="line.2571"></a>
<span class="sourceLineNo">2572</span><a name="line.2572"></a>
<span class="sourceLineNo">2573</span>    /**<a name="line.2573"></a>
<span class="sourceLineNo">2574</span>     * Sets the zoom in factor.<a name="line.2574"></a>
<span class="sourceLineNo">2575</span>     *<a name="line.2575"></a>
<span class="sourceLineNo">2576</span>     * @param factor  the factor.<a name="line.2576"></a>
<span class="sourceLineNo">2577</span>     *<a name="line.2577"></a>
<span class="sourceLineNo">2578</span>     * @see #getZoomInFactor()<a name="line.2578"></a>
<span class="sourceLineNo">2579</span>     */<a name="line.2579"></a>
<span class="sourceLineNo">2580</span>    public void setZoomInFactor(double factor) {<a name="line.2580"></a>
<span class="sourceLineNo">2581</span>        this.zoomInFactor = factor;<a name="line.2581"></a>
<span class="sourceLineNo">2582</span>    }<a name="line.2582"></a>
<span class="sourceLineNo">2583</span><a name="line.2583"></a>
<span class="sourceLineNo">2584</span>    /**<a name="line.2584"></a>
<span class="sourceLineNo">2585</span>     * Returns the zoom out factor.<a name="line.2585"></a>
<span class="sourceLineNo">2586</span>     *<a name="line.2586"></a>
<span class="sourceLineNo">2587</span>     * @return The zoom out factor.<a name="line.2587"></a>
<span class="sourceLineNo">2588</span>     *<a name="line.2588"></a>
<span class="sourceLineNo">2589</span>     * @see #setZoomOutFactor(double)<a name="line.2589"></a>
<span class="sourceLineNo">2590</span>     */<a name="line.2590"></a>
<span class="sourceLineNo">2591</span>    public double getZoomOutFactor() {<a name="line.2591"></a>
<span class="sourceLineNo">2592</span>        return this.zoomOutFactor;<a name="line.2592"></a>
<span class="sourceLineNo">2593</span>    }<a name="line.2593"></a>
<span class="sourceLineNo">2594</span><a name="line.2594"></a>
<span class="sourceLineNo">2595</span>    /**<a name="line.2595"></a>
<span class="sourceLineNo">2596</span>     * Sets the zoom out factor.<a name="line.2596"></a>
<span class="sourceLineNo">2597</span>     *<a name="line.2597"></a>
<span class="sourceLineNo">2598</span>     * @param factor  the factor.<a name="line.2598"></a>
<span class="sourceLineNo">2599</span>     *<a name="line.2599"></a>
<span class="sourceLineNo">2600</span>     * @see #getZoomOutFactor()<a name="line.2600"></a>
<span class="sourceLineNo">2601</span>     */<a name="line.2601"></a>
<span class="sourceLineNo">2602</span>    public void setZoomOutFactor(double factor) {<a name="line.2602"></a>
<span class="sourceLineNo">2603</span>        this.zoomOutFactor = factor;<a name="line.2603"></a>
<span class="sourceLineNo">2604</span>    }<a name="line.2604"></a>
<span class="sourceLineNo">2605</span><a name="line.2605"></a>
<span class="sourceLineNo">2606</span>    /**<a name="line.2606"></a>
<span class="sourceLineNo">2607</span>     * Draws zoom rectangle (if present).<a name="line.2607"></a>
<span class="sourceLineNo">2608</span>     * The drawing is performed in XOR mode, therefore<a name="line.2608"></a>
<span class="sourceLineNo">2609</span>     * when this method is called twice in a row,<a name="line.2609"></a>
<span class="sourceLineNo">2610</span>     * the second call will completely restore the state<a name="line.2610"></a>
<span class="sourceLineNo">2611</span>     * of the canvas.<a name="line.2611"></a>
<span class="sourceLineNo">2612</span>     *<a name="line.2612"></a>
<span class="sourceLineNo">2613</span>     * @param g2 the graphics device.<a name="line.2613"></a>
<span class="sourceLineNo">2614</span>     * @param xor  use XOR for drawing?<a name="line.2614"></a>
<span class="sourceLineNo">2615</span>     */<a name="line.2615"></a>
<span class="sourceLineNo">2616</span>    private void drawZoomRectangle(Graphics2D g2, boolean xor) {<a name="line.2616"></a>
<span class="sourceLineNo">2617</span>        if (this.zoomRectangle != null) {<a name="line.2617"></a>
<span class="sourceLineNo">2618</span>            if (xor) {<a name="line.2618"></a>
<span class="sourceLineNo">2619</span>                 // Set XOR mode to draw the zoom rectangle<a name="line.2619"></a>
<span class="sourceLineNo">2620</span>                g2.setXORMode(Color.gray);<a name="line.2620"></a>
<span class="sourceLineNo">2621</span>            }<a name="line.2621"></a>
<span class="sourceLineNo">2622</span>            if (this.fillZoomRectangle) {<a name="line.2622"></a>
<span class="sourceLineNo">2623</span>                g2.setPaint(this.zoomFillPaint);<a name="line.2623"></a>
<span class="sourceLineNo">2624</span>                g2.fill(this.zoomRectangle);<a name="line.2624"></a>
<span class="sourceLineNo">2625</span>            }<a name="line.2625"></a>
<span class="sourceLineNo">2626</span>            else {<a name="line.2626"></a>
<span class="sourceLineNo">2627</span>                g2.setPaint(this.zoomOutlinePaint);<a name="line.2627"></a>
<span class="sourceLineNo">2628</span>                g2.draw(this.zoomRectangle);<a name="line.2628"></a>
<span class="sourceLineNo">2629</span>            }<a name="line.2629"></a>
<span class="sourceLineNo">2630</span>            if (xor) {<a name="line.2630"></a>
<span class="sourceLineNo">2631</span>                // Reset to the default 'overwrite' mode<a name="line.2631"></a>
<span class="sourceLineNo">2632</span>                g2.setPaintMode();<a name="line.2632"></a>
<span class="sourceLineNo">2633</span>            }<a name="line.2633"></a>
<span class="sourceLineNo">2634</span>        }<a name="line.2634"></a>
<span class="sourceLineNo">2635</span>    }<a name="line.2635"></a>
<span class="sourceLineNo">2636</span><a name="line.2636"></a>
<span class="sourceLineNo">2637</span>    /**<a name="line.2637"></a>
<span class="sourceLineNo">2638</span>     * Draws a vertical line used to trace the mouse position to the horizontal<a name="line.2638"></a>
<span class="sourceLineNo">2639</span>     * axis.<a name="line.2639"></a>
<span class="sourceLineNo">2640</span>     *<a name="line.2640"></a>
<span class="sourceLineNo">2641</span>     * @param g2 the graphics device.<a name="line.2641"></a>
<span class="sourceLineNo">2642</span>     * @param x  the x-coordinate of the trace line.<a name="line.2642"></a>
<span class="sourceLineNo">2643</span>     */<a name="line.2643"></a>
<span class="sourceLineNo">2644</span>    private void drawHorizontalAxisTrace(Graphics2D g2, int x) {<a name="line.2644"></a>
<span class="sourceLineNo">2645</span><a name="line.2645"></a>
<span class="sourceLineNo">2646</span>        Rectangle2D dataArea = getScreenDataArea();<a name="line.2646"></a>
<span class="sourceLineNo">2647</span><a name="line.2647"></a>
<span class="sourceLineNo">2648</span>        g2.setXORMode(Color.orange);<a name="line.2648"></a>
<span class="sourceLineNo">2649</span>        if (((int) dataArea.getMinX() &lt; x) &amp;&amp; (x &lt; (int) dataArea.getMaxX())) {<a name="line.2649"></a>
<span class="sourceLineNo">2650</span><a name="line.2650"></a>
<span class="sourceLineNo">2651</span>            if (this.verticalTraceLine != null) {<a name="line.2651"></a>
<span class="sourceLineNo">2652</span>                g2.draw(this.verticalTraceLine);<a name="line.2652"></a>
<span class="sourceLineNo">2653</span>                this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x,<a name="line.2653"></a>
<span class="sourceLineNo">2654</span>                        (int) dataArea.getMaxY());<a name="line.2654"></a>
<span class="sourceLineNo">2655</span>            }<a name="line.2655"></a>
<span class="sourceLineNo">2656</span>            else {<a name="line.2656"></a>
<span class="sourceLineNo">2657</span>                this.verticalTraceLine = new Line2D.Float(x,<a name="line.2657"></a>
<span class="sourceLineNo">2658</span>                        (int) dataArea.getMinY(), x, (int) dataArea.getMaxY());<a name="line.2658"></a>
<span class="sourceLineNo">2659</span>            }<a name="line.2659"></a>
<span class="sourceLineNo">2660</span>            g2.draw(this.verticalTraceLine);<a name="line.2660"></a>
<span class="sourceLineNo">2661</span>        }<a name="line.2661"></a>
<span class="sourceLineNo">2662</span><a name="line.2662"></a>
<span class="sourceLineNo">2663</span>        // Reset to the default 'overwrite' mode<a name="line.2663"></a>
<span class="sourceLineNo">2664</span>        g2.setPaintMode();<a name="line.2664"></a>
<span class="sourceLineNo">2665</span>    }<a name="line.2665"></a>
<span class="sourceLineNo">2666</span><a name="line.2666"></a>
<span class="sourceLineNo">2667</span>    /**<a name="line.2667"></a>
<span class="sourceLineNo">2668</span>     * Draws a horizontal line used to trace the mouse position to the vertical<a name="line.2668"></a>
<span class="sourceLineNo">2669</span>     * axis.<a name="line.2669"></a>
<span class="sourceLineNo">2670</span>     *<a name="line.2670"></a>
<span class="sourceLineNo">2671</span>     * @param g2 the graphics device.<a name="line.2671"></a>
<span class="sourceLineNo">2672</span>     * @param y  the y-coordinate of the trace line.<a name="line.2672"></a>
<span class="sourceLineNo">2673</span>     */<a name="line.2673"></a>
<span class="sourceLineNo">2674</span>    private void drawVerticalAxisTrace(Graphics2D g2, int y) {<a name="line.2674"></a>
<span class="sourceLineNo">2675</span><a name="line.2675"></a>
<span class="sourceLineNo">2676</span>        Rectangle2D dataArea = getScreenDataArea();<a name="line.2676"></a>
<span class="sourceLineNo">2677</span><a name="line.2677"></a>
<span class="sourceLineNo">2678</span>        g2.setXORMode(Color.orange);<a name="line.2678"></a>
<span class="sourceLineNo">2679</span>        if (((int) dataArea.getMinY() &lt; y) &amp;&amp; (y &lt; (int) dataArea.getMaxY())) {<a name="line.2679"></a>
<span class="sourceLineNo">2680</span><a name="line.2680"></a>
<span class="sourceLineNo">2681</span>            if (this.horizontalTraceLine != null) {<a name="line.2681"></a>
<span class="sourceLineNo">2682</span>                g2.draw(this.horizontalTraceLine);<a name="line.2682"></a>
<span class="sourceLineNo">2683</span>                this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y,<a name="line.2683"></a>
<span class="sourceLineNo">2684</span>                        (int) dataArea.getMaxX(), y);<a name="line.2684"></a>
<span class="sourceLineNo">2685</span>            }<a name="line.2685"></a>
<span class="sourceLineNo">2686</span>            else {<a name="line.2686"></a>
<span class="sourceLineNo">2687</span>                this.horizontalTraceLine = new Line2D.Float(<a name="line.2687"></a>
<span class="sourceLineNo">2688</span>                        (int) dataArea.getMinX(), y, (int) dataArea.getMaxX(),<a name="line.2688"></a>
<span class="sourceLineNo">2689</span>                        y);<a name="line.2689"></a>
<span class="sourceLineNo">2690</span>            }<a name="line.2690"></a>
<span class="sourceLineNo">2691</span>            g2.draw(this.horizontalTraceLine);<a name="line.2691"></a>
<span class="sourceLineNo">2692</span>        }<a name="line.2692"></a>
<span class="sourceLineNo">2693</span><a name="line.2693"></a>
<span class="sourceLineNo">2694</span>        // Reset to the default 'overwrite' mode<a name="line.2694"></a>
<span class="sourceLineNo">2695</span>        g2.setPaintMode();<a name="line.2695"></a>
<span class="sourceLineNo">2696</span>    }<a name="line.2696"></a>
<span class="sourceLineNo">2697</span><a name="line.2697"></a>
<span class="sourceLineNo">2698</span>    /**<a name="line.2698"></a>
<span class="sourceLineNo">2699</span>     * Displays a dialog that allows the user to edit the properties for the<a name="line.2699"></a>
<span class="sourceLineNo">2700</span>     * current chart.<a name="line.2700"></a>
<span class="sourceLineNo">2701</span>     *<a name="line.2701"></a>
<span class="sourceLineNo">2702</span>     * @since 1.0.3<a name="line.2702"></a>
<span class="sourceLineNo">2703</span>     */<a name="line.2703"></a>
<span class="sourceLineNo">2704</span>    public void doEditChartProperties() {<a name="line.2704"></a>
<span class="sourceLineNo">2705</span><a name="line.2705"></a>
<span class="sourceLineNo">2706</span>        ChartEditor editor = ChartEditorManager.getChartEditor(this.chart);<a name="line.2706"></a>
<span class="sourceLineNo">2707</span>        int result = JOptionPane.showConfirmDialog(this, editor,<a name="line.2707"></a>
<span class="sourceLineNo">2708</span>                localizationResources.getString("Chart_Properties"),<a name="line.2708"></a>
<span class="sourceLineNo">2709</span>                JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);<a name="line.2709"></a>
<span class="sourceLineNo">2710</span>        if (result == JOptionPane.OK_OPTION) {<a name="line.2710"></a>
<span class="sourceLineNo">2711</span>            editor.updateChart(this.chart);<a name="line.2711"></a>
<span class="sourceLineNo">2712</span>        }<a name="line.2712"></a>
<span class="sourceLineNo">2713</span><a name="line.2713"></a>
<span class="sourceLineNo">2714</span>    }<a name="line.2714"></a>
<span class="sourceLineNo">2715</span><a name="line.2715"></a>
<span class="sourceLineNo">2716</span>    /**<a name="line.2716"></a>
<span class="sourceLineNo">2717</span>     * Copies the current chart to the system clipboard.<a name="line.2717"></a>
<span class="sourceLineNo">2718</span>     * <a name="line.2718"></a>
<span class="sourceLineNo">2719</span>     * @since 1.0.13<a name="line.2719"></a>
<span class="sourceLineNo">2720</span>     */<a name="line.2720"></a>
<span class="sourceLineNo">2721</span>    public void doCopy() {<a name="line.2721"></a>
<span class="sourceLineNo">2722</span>        Clipboard systemClipboard<a name="line.2722"></a>
<span class="sourceLineNo">2723</span>                = Toolkit.getDefaultToolkit().getSystemClipboard();<a name="line.2723"></a>
<span class="sourceLineNo">2724</span>        Insets insets = getInsets();<a name="line.2724"></a>
<span class="sourceLineNo">2725</span>        int w = getWidth() - insets.left - insets.right;<a name="line.2725"></a>
<span class="sourceLineNo">2726</span>        int h = getHeight() - insets.top - insets.bottom;<a name="line.2726"></a>
<span class="sourceLineNo">2727</span>        ChartTransferable selection = new ChartTransferable(this.chart, w, h,<a name="line.2727"></a>
<span class="sourceLineNo">2728</span>                getMinimumDrawWidth(), getMinimumDrawHeight(),<a name="line.2728"></a>
<span class="sourceLineNo">2729</span>                getMaximumDrawWidth(), getMaximumDrawHeight(), true);<a name="line.2729"></a>
<span class="sourceLineNo">2730</span>        systemClipboard.setContents(selection, null);<a name="line.2730"></a>
<span class="sourceLineNo">2731</span>    }<a name="line.2731"></a>
<span class="sourceLineNo">2732</span><a name="line.2732"></a>
<span class="sourceLineNo">2733</span>    /**<a name="line.2733"></a>
<span class="sourceLineNo">2734</span>     * Opens a file chooser and gives the user an opportunity to save the chart<a name="line.2734"></a>
<span class="sourceLineNo">2735</span>     * in PNG format.<a name="line.2735"></a>
<span class="sourceLineNo">2736</span>     *<a name="line.2736"></a>
<span class="sourceLineNo">2737</span>     * @throws IOException if there is an I/O error.<a name="line.2737"></a>
<span class="sourceLineNo">2738</span>     */<a name="line.2738"></a>
<span class="sourceLineNo">2739</span>    public void doSaveAs() throws IOException {<a name="line.2739"></a>
<span class="sourceLineNo">2740</span><a name="line.2740"></a>
<span class="sourceLineNo">2741</span>        JFileChooser fileChooser = new JFileChooser();<a name="line.2741"></a>
<span class="sourceLineNo">2742</span>        fileChooser.setCurrentDirectory(this.defaultDirectoryForSaveAs);<a name="line.2742"></a>
<span class="sourceLineNo">2743</span>        ExtensionFileFilter filter = new ExtensionFileFilter(<a name="line.2743"></a>
<span class="sourceLineNo">2744</span>                localizationResources.getString("PNG_Image_Files"), ".png");<a name="line.2744"></a>
<span class="sourceLineNo">2745</span>        fileChooser.addChoosableFileFilter(filter);<a name="line.2745"></a>
<span class="sourceLineNo">2746</span><a name="line.2746"></a>
<span class="sourceLineNo">2747</span>        int option = fileChooser.showSaveDialog(this);<a name="line.2747"></a>
<span class="sourceLineNo">2748</span>        if (option == JFileChooser.APPROVE_OPTION) {<a name="line.2748"></a>
<span class="sourceLineNo">2749</span>            String filename = fileChooser.getSelectedFile().getPath();<a name="line.2749"></a>
<span class="sourceLineNo">2750</span>            if (isEnforceFileExtensions()) {<a name="line.2750"></a>
<span class="sourceLineNo">2751</span>                if (!filename.endsWith(".png")) {<a name="line.2751"></a>
<span class="sourceLineNo">2752</span>                    filename = filename + ".png";<a name="line.2752"></a>
<span class="sourceLineNo">2753</span>                }<a name="line.2753"></a>
<span class="sourceLineNo">2754</span>            }<a name="line.2754"></a>
<span class="sourceLineNo">2755</span>            ChartUtilities.saveChartAsPNG(new File(filename), this.chart,<a name="line.2755"></a>
<span class="sourceLineNo">2756</span>                    getWidth(), getHeight());<a name="line.2756"></a>
<span class="sourceLineNo">2757</span>        }<a name="line.2757"></a>
<span class="sourceLineNo">2758</span><a name="line.2758"></a>
<span class="sourceLineNo">2759</span>    }<a name="line.2759"></a>
<span class="sourceLineNo">2760</span><a name="line.2760"></a>
<span class="sourceLineNo">2761</span>    /**<a name="line.2761"></a>
<span class="sourceLineNo">2762</span>     * Creates a print job for the chart.<a name="line.2762"></a>
<span class="sourceLineNo">2763</span>     */<a name="line.2763"></a>
<span class="sourceLineNo">2764</span>    public void createChartPrintJob() {<a name="line.2764"></a>
<span class="sourceLineNo">2765</span><a name="line.2765"></a>
<span class="sourceLineNo">2766</span>        PrinterJob job = PrinterJob.getPrinterJob();<a name="line.2766"></a>
<span class="sourceLineNo">2767</span>        PageFormat pf = job.defaultPage();<a name="line.2767"></a>
<span class="sourceLineNo">2768</span>        PageFormat pf2 = job.pageDialog(pf);<a name="line.2768"></a>
<span class="sourceLineNo">2769</span>        if (pf2 != pf) {<a name="line.2769"></a>
<span class="sourceLineNo">2770</span>            job.setPrintable(this, pf2);<a name="line.2770"></a>
<span class="sourceLineNo">2771</span>            if (job.printDialog()) {<a name="line.2771"></a>
<span class="sourceLineNo">2772</span>                try {<a name="line.2772"></a>
<span class="sourceLineNo">2773</span>                    job.print();<a name="line.2773"></a>
<span class="sourceLineNo">2774</span>                }<a name="line.2774"></a>
<span class="sourceLineNo">2775</span>                catch (PrinterException e) {<a name="line.2775"></a>
<span class="sourceLineNo">2776</span>                    JOptionPane.showMessageDialog(this, e);<a name="line.2776"></a>
<span class="sourceLineNo">2777</span>                }<a name="line.2777"></a>
<span class="sourceLineNo">2778</span>            }<a name="line.2778"></a>
<span class="sourceLineNo">2779</span>        }<a name="line.2779"></a>
<span class="sourceLineNo">2780</span><a name="line.2780"></a>
<span class="sourceLineNo">2781</span>    }<a name="line.2781"></a>
<span class="sourceLineNo">2782</span><a name="line.2782"></a>
<span class="sourceLineNo">2783</span>    /**<a name="line.2783"></a>
<span class="sourceLineNo">2784</span>     * Prints the chart on a single page.<a name="line.2784"></a>
<span class="sourceLineNo">2785</span>     *<a name="line.2785"></a>
<span class="sourceLineNo">2786</span>     * @param g  the graphics context.<a name="line.2786"></a>
<span class="sourceLineNo">2787</span>     * @param pf  the page format to use.<a name="line.2787"></a>
<span class="sourceLineNo">2788</span>     * @param pageIndex  the index of the page. If not &lt;code&gt;0&lt;/code&gt;, nothing<a name="line.2788"></a>
<span class="sourceLineNo">2789</span>     *                   gets print.<a name="line.2789"></a>
<span class="sourceLineNo">2790</span>     *<a name="line.2790"></a>
<span class="sourceLineNo">2791</span>     * @return The result of printing.<a name="line.2791"></a>
<span class="sourceLineNo">2792</span>     */<a name="line.2792"></a>
<span class="sourceLineNo">2793</span>    public int print(Graphics g, PageFormat pf, int pageIndex) {<a name="line.2793"></a>
<span class="sourceLineNo">2794</span><a name="line.2794"></a>
<span class="sourceLineNo">2795</span>        if (pageIndex != 0) {<a name="line.2795"></a>
<span class="sourceLineNo">2796</span>            return NO_SUCH_PAGE;<a name="line.2796"></a>
<span class="sourceLineNo">2797</span>        }<a name="line.2797"></a>
<span class="sourceLineNo">2798</span>        Graphics2D g2 = (Graphics2D) g;<a name="line.2798"></a>
<span class="sourceLineNo">2799</span>        double x = pf.getImageableX();<a name="line.2799"></a>
<span class="sourceLineNo">2800</span>        double y = pf.getImageableY();<a name="line.2800"></a>
<span class="sourceLineNo">2801</span>        double w = pf.getImageableWidth();<a name="line.2801"></a>
<span class="sourceLineNo">2802</span>        double h = pf.getImageableHeight();<a name="line.2802"></a>
<span class="sourceLineNo">2803</span>        this.chart.draw(g2, new Rectangle2D.Double(x, y, w, h), this.anchor,<a name="line.2803"></a>
<span class="sourceLineNo">2804</span>                null);<a name="line.2804"></a>
<span class="sourceLineNo">2805</span>        return PAGE_EXISTS;<a name="line.2805"></a>
<span class="sourceLineNo">2806</span><a name="line.2806"></a>
<span class="sourceLineNo">2807</span>    }<a name="line.2807"></a>
<span class="sourceLineNo">2808</span><a name="line.2808"></a>
<span class="sourceLineNo">2809</span>    /**<a name="line.2809"></a>
<span class="sourceLineNo">2810</span>     * Adds a listener to the list of objects listening for chart mouse events.<a name="line.2810"></a>
<span class="sourceLineNo">2811</span>     *<a name="line.2811"></a>
<span class="sourceLineNo">2812</span>     * @param listener  the listener (&lt;code&gt;null&lt;/code&gt; not permitted).<a name="line.2812"></a>
<span class="sourceLineNo">2813</span>     */<a name="line.2813"></a>
<span class="sourceLineNo">2814</span>    public void addChartMouseListener(ChartMouseListener listener) {<a name="line.2814"></a>
<span class="sourceLineNo">2815</span>        if (listener == null) {<a name="line.2815"></a>
<span class="sourceLineNo">2816</span>            throw new IllegalArgumentException("Null 'listener' argument.");<a name="line.2816"></a>
<span class="sourceLineNo">2817</span>        }<a name="line.2817"></a>
<span class="sourceLineNo">2818</span>        this.chartMouseListeners.add(ChartMouseListener.class, listener);<a name="line.2818"></a>
<span class="sourceLineNo">2819</span>    }<a name="line.2819"></a>
<span class="sourceLineNo">2820</span><a name="line.2820"></a>
<span class="sourceLineNo">2821</span>    /**<a name="line.2821"></a>
<span class="sourceLineNo">2822</span>     * Removes a listener from the list of objects listening for chart mouse<a name="line.2822"></a>
<span class="sourceLineNo">2823</span>     * events.<a name="line.2823"></a>
<span class="sourceLineNo">2824</span>     *<a name="line.2824"></a>
<span class="sourceLineNo">2825</span>     * @param listener  the listener.<a name="line.2825"></a>
<span class="sourceLineNo">2826</span>     */<a name="line.2826"></a>
<span class="sourceLineNo">2827</span>    public void removeChartMouseListener(ChartMouseListener listener) {<a name="line.2827"></a>
<span class="sourceLineNo">2828</span>        this.chartMouseListeners.remove(ChartMouseListener.class, listener);<a name="line.2828"></a>
<span class="sourceLineNo">2829</span>    }<a name="line.2829"></a>
<span class="sourceLineNo">2830</span><a name="line.2830"></a>
<span class="sourceLineNo">2831</span>    /**<a name="line.2831"></a>
<span class="sourceLineNo">2832</span>     * Returns an array of the listeners of the given type registered with the<a name="line.2832"></a>
<span class="sourceLineNo">2833</span>     * panel.<a name="line.2833"></a>
<span class="sourceLineNo">2834</span>     *<a name="line.2834"></a>
<span class="sourceLineNo">2835</span>     * @param listenerType  the listener type.<a name="line.2835"></a>
<span class="sourceLineNo">2836</span>     *<a name="line.2836"></a>
<span class="sourceLineNo">2837</span>     * @return An array of listeners.<a name="line.2837"></a>
<span class="sourceLineNo">2838</span>     */<a name="line.2838"></a>
<span class="sourceLineNo">2839</span>    public EventListener[] getListeners(Class listenerType) {<a name="line.2839"></a>
<span class="sourceLineNo">2840</span>        if (listenerType == ChartMouseListener.class) {<a name="line.2840"></a>
<span class="sourceLineNo">2841</span>            // fetch listeners from local storage<a name="line.2841"></a>
<span class="sourceLineNo">2842</span>            return this.chartMouseListeners.getListeners(listenerType);<a name="line.2842"></a>
<span class="sourceLineNo">2843</span>        }<a name="line.2843"></a>
<span class="sourceLineNo">2844</span>        else {<a name="line.2844"></a>
<span class="sourceLineNo">2845</span>            return super.getListeners(listenerType);<a name="line.2845"></a>
<span class="sourceLineNo">2846</span>        }<a name="line.2846"></a>
<span class="sourceLineNo">2847</span>    }<a name="line.2847"></a>
<span class="sourceLineNo">2848</span><a name="line.2848"></a>
<span class="sourceLineNo">2849</span>    /**<a name="line.2849"></a>
<span class="sourceLineNo">2850</span>     * Creates a popup menu for the panel.<a name="line.2850"></a>
<span class="sourceLineNo">2851</span>     *<a name="line.2851"></a>
<span class="sourceLineNo">2852</span>     * @param properties  include a menu item for the chart property editor.<a name="line.2852"></a>
<span class="sourceLineNo">2853</span>     * @param save  include a menu item for saving the chart.<a name="line.2853"></a>
<span class="sourceLineNo">2854</span>     * @param print  include a menu item for printing the chart.<a name="line.2854"></a>
<span class="sourceLineNo">2855</span>     * @param zoom  include menu items for zooming.<a name="line.2855"></a>
<span class="sourceLineNo">2856</span>     *<a name="line.2856"></a>
<span class="sourceLineNo">2857</span>     * @return The popup menu.<a name="line.2857"></a>
<span class="sourceLineNo">2858</span>     */<a name="line.2858"></a>
<span class="sourceLineNo">2859</span>    protected JPopupMenu createPopupMenu(boolean properties, boolean save,<a name="line.2859"></a>
<span class="sourceLineNo">2860</span>            boolean print, boolean zoom) {<a name="line.2860"></a>
<span class="sourceLineNo">2861</span>        return createPopupMenu(properties, false, save, print, zoom);<a name="line.2861"></a>
<span class="sourceLineNo">2862</span>    }<a name="line.2862"></a>
<span class="sourceLineNo">2863</span><a name="line.2863"></a>
<span class="sourceLineNo">2864</span>    /**<a name="line.2864"></a>
<span class="sourceLineNo">2865</span>     * Creates a popup menu for the panel.<a name="line.2865"></a>
<span class="sourceLineNo">2866</span>     *<a name="line.2866"></a>
<span class="sourceLineNo">2867</span>     * @param properties  include a menu item for the chart property editor.<a name="line.2867"></a>
<span class="sourceLineNo">2868</span>     * @param copy include a menu item for copying to the clipboard.<a name="line.2868"></a>
<span class="sourceLineNo">2869</span>     * @param save  include a menu item for saving the chart.<a name="line.2869"></a>
<span class="sourceLineNo">2870</span>     * @param print  include a menu item for printing the chart.<a name="line.2870"></a>
<span class="sourceLineNo">2871</span>     * @param zoom  include menu items for zooming.<a name="line.2871"></a>
<span class="sourceLineNo">2872</span>     *<a name="line.2872"></a>
<span class="sourceLineNo">2873</span>     * @return The popup menu.<a name="line.2873"></a>
<span class="sourceLineNo">2874</span>     *<a name="line.2874"></a>
<span class="sourceLineNo">2875</span>     * @since 1.0.13<a name="line.2875"></a>
<span class="sourceLineNo">2876</span>     */<a name="line.2876"></a>
<span class="sourceLineNo">2877</span>    protected JPopupMenu createPopupMenu(boolean properties,<a name="line.2877"></a>
<span class="sourceLineNo">2878</span>            boolean copy, boolean save, boolean print, boolean zoom) {<a name="line.2878"></a>
<span class="sourceLineNo">2879</span><a name="line.2879"></a>
<span class="sourceLineNo">2880</span>        JPopupMenu result = new JPopupMenu(localizationResources.getString("Chart") + ":");<a name="line.2880"></a>
<span class="sourceLineNo">2881</span>        boolean separator = false;<a name="line.2881"></a>
<span class="sourceLineNo">2882</span><a name="line.2882"></a>
<span class="sourceLineNo">2883</span>        if (properties) {<a name="line.2883"></a>
<span class="sourceLineNo">2884</span>            JMenuItem propertiesItem = new JMenuItem(<a name="line.2884"></a>
<span class="sourceLineNo">2885</span>                    localizationResources.getString("Properties..."));<a name="line.2885"></a>
<span class="sourceLineNo">2886</span>            propertiesItem.setActionCommand(PROPERTIES_COMMAND);<a name="line.2886"></a>
<span class="sourceLineNo">2887</span>            propertiesItem.addActionListener(this);<a name="line.2887"></a>
<span class="sourceLineNo">2888</span>            result.add(propertiesItem);<a name="line.2888"></a>
<span class="sourceLineNo">2889</span>            separator = true;<a name="line.2889"></a>
<span class="sourceLineNo">2890</span>        }<a name="line.2890"></a>
<span class="sourceLineNo">2891</span><a name="line.2891"></a>
<span class="sourceLineNo">2892</span>        if (copy) {<a name="line.2892"></a>
<span class="sourceLineNo">2893</span>            if (separator) {<a name="line.2893"></a>
<span class="sourceLineNo">2894</span>                result.addSeparator();<a name="line.2894"></a>
<span class="sourceLineNo">2895</span>                separator = false;<a name="line.2895"></a>
<span class="sourceLineNo">2896</span>            }<a name="line.2896"></a>
<span class="sourceLineNo">2897</span>            JMenuItem copyItem = new JMenuItem(<a name="line.2897"></a>
<span class="sourceLineNo">2898</span>                    localizationResources.getString("Copy"));<a name="line.2898"></a>
<span class="sourceLineNo">2899</span>            copyItem.setActionCommand(COPY_COMMAND);<a name="line.2899"></a>
<span class="sourceLineNo">2900</span>            copyItem.addActionListener(this);<a name="line.2900"></a>
<span class="sourceLineNo">2901</span>            result.add(copyItem);<a name="line.2901"></a>
<span class="sourceLineNo">2902</span>            separator = !save;<a name="line.2902"></a>
<span class="sourceLineNo">2903</span>        }<a name="line.2903"></a>
<span class="sourceLineNo">2904</span><a name="line.2904"></a>
<span class="sourceLineNo">2905</span>        if (save) {<a name="line.2905"></a>
<span class="sourceLineNo">2906</span>            if (separator) {<a name="line.2906"></a>
<span class="sourceLineNo">2907</span>                result.addSeparator();<a name="line.2907"></a>
<span class="sourceLineNo">2908</span>                separator = false;<a name="line.2908"></a>
<span class="sourceLineNo">2909</span>            }<a name="line.2909"></a>
<span class="sourceLineNo">2910</span>            JMenuItem saveItem = new JMenuItem(<a name="line.2910"></a>
<span class="sourceLineNo">2911</span>                    localizationResources.getString("Save_as..."));<a name="line.2911"></a>
<span class="sourceLineNo">2912</span>            saveItem.setActionCommand(SAVE_COMMAND);<a name="line.2912"></a>
<span class="sourceLineNo">2913</span>            saveItem.addActionListener(this);<a name="line.2913"></a>
<span class="sourceLineNo">2914</span>            result.add(saveItem);<a name="line.2914"></a>
<span class="sourceLineNo">2915</span>            separator = true;<a name="line.2915"></a>
<span class="sourceLineNo">2916</span>        }<a name="line.2916"></a>
<span class="sourceLineNo">2917</span><a name="line.2917"></a>
<span class="sourceLineNo">2918</span>        if (print) {<a name="line.2918"></a>
<span class="sourceLineNo">2919</span>            if (separator) {<a name="line.2919"></a>
<span class="sourceLineNo">2920</span>                result.addSeparator();<a name="line.2920"></a>
<span class="sourceLineNo">2921</span>                separator = false;<a name="line.2921"></a>
<span class="sourceLineNo">2922</span>            }<a name="line.2922"></a>
<span class="sourceLineNo">2923</span>            JMenuItem printItem = new JMenuItem(<a name="line.2923"></a>
<span class="sourceLineNo">2924</span>                    localizationResources.getString("Print..."));<a name="line.2924"></a>
<span class="sourceLineNo">2925</span>            printItem.setActionCommand(PRINT_COMMAND);<a name="line.2925"></a>
<span class="sourceLineNo">2926</span>            printItem.addActionListener(this);<a name="line.2926"></a>
<span class="sourceLineNo">2927</span>            result.add(printItem);<a name="line.2927"></a>
<span class="sourceLineNo">2928</span>            separator = true;<a name="line.2928"></a>
<span class="sourceLineNo">2929</span>        }<a name="line.2929"></a>
<span class="sourceLineNo">2930</span><a name="line.2930"></a>
<span class="sourceLineNo">2931</span>        if (zoom) {<a name="line.2931"></a>
<span class="sourceLineNo">2932</span>            if (separator) {<a name="line.2932"></a>
<span class="sourceLineNo">2933</span>                result.addSeparator();<a name="line.2933"></a>
<span class="sourceLineNo">2934</span>                separator = false;<a name="line.2934"></a>
<span class="sourceLineNo">2935</span>            }<a name="line.2935"></a>
<span class="sourceLineNo">2936</span><a name="line.2936"></a>
<span class="sourceLineNo">2937</span>            JMenu zoomInMenu = new JMenu(<a name="line.2937"></a>
<span class="sourceLineNo">2938</span>                    localizationResources.getString("Zoom_In"));<a name="line.2938"></a>
<span class="sourceLineNo">2939</span><a name="line.2939"></a>
<span class="sourceLineNo">2940</span>            this.zoomInBothMenuItem = new JMenuItem(<a name="line.2940"></a>
<span class="sourceLineNo">2941</span>                    localizationResources.getString("All_Axes"));<a name="line.2941"></a>
<span class="sourceLineNo">2942</span>            this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND);<a name="line.2942"></a>
<span class="sourceLineNo">2943</span>            this.zoomInBothMenuItem.addActionListener(this);<a name="line.2943"></a>
<span class="sourceLineNo">2944</span>            zoomInMenu.add(this.zoomInBothMenuItem);<a name="line.2944"></a>
<span class="sourceLineNo">2945</span><a name="line.2945"></a>
<span class="sourceLineNo">2946</span>            zoomInMenu.addSeparator();<a name="line.2946"></a>
<span class="sourceLineNo">2947</span><a name="line.2947"></a>
<span class="sourceLineNo">2948</span>            this.zoomInDomainMenuItem = new JMenuItem(<a name="line.2948"></a>
<span class="sourceLineNo">2949</span>                    localizationResources.getString("Domain_Axis"));<a name="line.2949"></a>
<span class="sourceLineNo">2950</span>            this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND);<a name="line.2950"></a>
<span class="sourceLineNo">2951</span>            this.zoomInDomainMenuItem.addActionListener(this);<a name="line.2951"></a>
<span class="sourceLineNo">2952</span>            zoomInMenu.add(this.zoomInDomainMenuItem);<a name="line.2952"></a>
<span class="sourceLineNo">2953</span><a name="line.2953"></a>
<span class="sourceLineNo">2954</span>            this.zoomInRangeMenuItem = new JMenuItem(<a name="line.2954"></a>
<span class="sourceLineNo">2955</span>                    localizationResources.getString("Range_Axis"));<a name="line.2955"></a>
<span class="sourceLineNo">2956</span>            this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND);<a name="line.2956"></a>
<span class="sourceLineNo">2957</span>            this.zoomInRangeMenuItem.addActionListener(this);<a name="line.2957"></a>
<span class="sourceLineNo">2958</span>            zoomInMenu.add(this.zoomInRangeMenuItem);<a name="line.2958"></a>
<span class="sourceLineNo">2959</span><a name="line.2959"></a>
<span class="sourceLineNo">2960</span>            result.add(zoomInMenu);<a name="line.2960"></a>
<span class="sourceLineNo">2961</span><a name="line.2961"></a>
<span class="sourceLineNo">2962</span>            JMenu zoomOutMenu = new JMenu(<a name="line.2962"></a>
<span class="sourceLineNo">2963</span>                    localizationResources.getString("Zoom_Out"));<a name="line.2963"></a>
<span class="sourceLineNo">2964</span><a name="line.2964"></a>
<span class="sourceLineNo">2965</span>            this.zoomOutBothMenuItem = new JMenuItem(<a name="line.2965"></a>
<span class="sourceLineNo">2966</span>                    localizationResources.getString("All_Axes"));<a name="line.2966"></a>
<span class="sourceLineNo">2967</span>            this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND);<a name="line.2967"></a>
<span class="sourceLineNo">2968</span>            this.zoomOutBothMenuItem.addActionListener(this);<a name="line.2968"></a>
<span class="sourceLineNo">2969</span>            zoomOutMenu.add(this.zoomOutBothMenuItem);<a name="line.2969"></a>
<span class="sourceLineNo">2970</span><a name="line.2970"></a>
<span class="sourceLineNo">2971</span>            zoomOutMenu.addSeparator();<a name="line.2971"></a>
<span class="sourceLineNo">2972</span><a name="line.2972"></a>
<span class="sourceLineNo">2973</span>            this.zoomOutDomainMenuItem = new JMenuItem(<a name="line.2973"></a>
<span class="sourceLineNo">2974</span>                    localizationResources.getString("Domain_Axis"));<a name="line.2974"></a>
<span class="sourceLineNo">2975</span>            this.zoomOutDomainMenuItem.setActionCommand(<a name="line.2975"></a>
<span class="sourceLineNo">2976</span>                    ZOOM_OUT_DOMAIN_COMMAND);<a name="line.2976"></a>
<span class="sourceLineNo">2977</span>            this.zoomOutDomainMenuItem.addActionListener(this);<a name="line.2977"></a>
<span class="sourceLineNo">2978</span>            zoomOutMenu.add(this.zoomOutDomainMenuItem);<a name="line.2978"></a>
<span class="sourceLineNo">2979</span><a name="line.2979"></a>
<span class="sourceLineNo">2980</span>            this.zoomOutRangeMenuItem = new JMenuItem(<a name="line.2980"></a>
<span class="sourceLineNo">2981</span>                    localizationResources.getString("Range_Axis"));<a name="line.2981"></a>
<span class="sourceLineNo">2982</span>            this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND);<a name="line.2982"></a>
<span class="sourceLineNo">2983</span>            this.zoomOutRangeMenuItem.addActionListener(this);<a name="line.2983"></a>
<span class="sourceLineNo">2984</span>            zoomOutMenu.add(this.zoomOutRangeMenuItem);<a name="line.2984"></a>
<span class="sourceLineNo">2985</span><a name="line.2985"></a>
<span class="sourceLineNo">2986</span>            result.add(zoomOutMenu);<a name="line.2986"></a>
<span class="sourceLineNo">2987</span><a name="line.2987"></a>
<span class="sourceLineNo">2988</span>            JMenu autoRangeMenu = new JMenu(<a name="line.2988"></a>
<span class="sourceLineNo">2989</span>                    localizationResources.getString("Auto_Range"));<a name="line.2989"></a>
<span class="sourceLineNo">2990</span><a name="line.2990"></a>
<span class="sourceLineNo">2991</span>            this.zoomResetBothMenuItem = new JMenuItem(<a name="line.2991"></a>
<span class="sourceLineNo">2992</span>                    localizationResources.getString("All_Axes"));<a name="line.2992"></a>
<span class="sourceLineNo">2993</span>            this.zoomResetBothMenuItem.setActionCommand(<a name="line.2993"></a>
<span class="sourceLineNo">2994</span>                    ZOOM_RESET_BOTH_COMMAND);<a name="line.2994"></a>
<span class="sourceLineNo">2995</span>            this.zoomResetBothMenuItem.addActionListener(this);<a name="line.2995"></a>
<span class="sourceLineNo">2996</span>            autoRangeMenu.add(this.zoomResetBothMenuItem);<a name="line.2996"></a>
<span class="sourceLineNo">2997</span><a name="line.2997"></a>
<span class="sourceLineNo">2998</span>            autoRangeMenu.addSeparator();<a name="line.2998"></a>
<span class="sourceLineNo">2999</span>            this.zoomResetDomainMenuItem = new JMenuItem(<a name="line.2999"></a>
<span class="sourceLineNo">3000</span>                    localizationResources.getString("Domain_Axis"));<a name="line.3000"></a>
<span class="sourceLineNo">3001</span>            this.zoomResetDomainMenuItem.setActionCommand(<a name="line.3001"></a>
<span class="sourceLineNo">3002</span>                    ZOOM_RESET_DOMAIN_COMMAND);<a name="line.3002"></a>
<span class="sourceLineNo">3003</span>            this.zoomResetDomainMenuItem.addActionListener(this);<a name="line.3003"></a>
<span class="sourceLineNo">3004</span>            autoRangeMenu.add(this.zoomResetDomainMenuItem);<a name="line.3004"></a>
<span class="sourceLineNo">3005</span><a name="line.3005"></a>
<span class="sourceLineNo">3006</span>            this.zoomResetRangeMenuItem = new JMenuItem(<a name="line.3006"></a>
<span class="sourceLineNo">3007</span>                    localizationResources.getString("Range_Axis"));<a name="line.3007"></a>
<span class="sourceLineNo">3008</span>            this.zoomResetRangeMenuItem.setActionCommand(<a name="line.3008"></a>
<span class="sourceLineNo">3009</span>                    ZOOM_RESET_RANGE_COMMAND);<a name="line.3009"></a>
<span class="sourceLineNo">3010</span>            this.zoomResetRangeMenuItem.addActionListener(this);<a name="line.3010"></a>
<span class="sourceLineNo">3011</span>            autoRangeMenu.add(this.zoomResetRangeMenuItem);<a name="line.3011"></a>
<span class="sourceLineNo">3012</span><a name="line.3012"></a>
<span class="sourceLineNo">3013</span>            result.addSeparator();<a name="line.3013"></a>
<span class="sourceLineNo">3014</span>            result.add(autoRangeMenu);<a name="line.3014"></a>
<span class="sourceLineNo">3015</span><a name="line.3015"></a>
<span class="sourceLineNo">3016</span>        }<a name="line.3016"></a>
<span class="sourceLineNo">3017</span><a name="line.3017"></a>
<span class="sourceLineNo">3018</span>        return result;<a name="line.3018"></a>
<span class="sourceLineNo">3019</span><a name="line.3019"></a>
<span class="sourceLineNo">3020</span>    }<a name="line.3020"></a>
<span class="sourceLineNo">3021</span><a name="line.3021"></a>
<span class="sourceLineNo">3022</span>    /**<a name="line.3022"></a>
<span class="sourceLineNo">3023</span>     * The idea is to modify the zooming options depending on the type of chart<a name="line.3023"></a>
<span class="sourceLineNo">3024</span>     * being displayed by the panel.<a name="line.3024"></a>
<span class="sourceLineNo">3025</span>     *<a name="line.3025"></a>
<span class="sourceLineNo">3026</span>     * @param x  horizontal position of the popup.<a name="line.3026"></a>
<span class="sourceLineNo">3027</span>     * @param y  vertical position of the popup.<a name="line.3027"></a>
<span class="sourceLineNo">3028</span>     */<a name="line.3028"></a>
<span class="sourceLineNo">3029</span>    protected void displayPopupMenu(int x, int y) {<a name="line.3029"></a>
<span class="sourceLineNo">3030</span><a name="line.3030"></a>
<span class="sourceLineNo">3031</span>        if (this.popup == null) {<a name="line.3031"></a>
<span class="sourceLineNo">3032</span>            return;<a name="line.3032"></a>
<span class="sourceLineNo">3033</span>        }<a name="line.3033"></a>
<span class="sourceLineNo">3034</span><a name="line.3034"></a>
<span class="sourceLineNo">3035</span>        // go through each zoom menu item and decide whether or not to<a name="line.3035"></a>
<span class="sourceLineNo">3036</span>        // enable it...<a name="line.3036"></a>
<span class="sourceLineNo">3037</span>        boolean isDomainZoomable = false;<a name="line.3037"></a>
<span class="sourceLineNo">3038</span>        boolean isRangeZoomable = false;<a name="line.3038"></a>
<span class="sourceLineNo">3039</span>        Plot plot = (this.chart != null ? this.chart.getPlot() : null);<a name="line.3039"></a>
<span class="sourceLineNo">3040</span>        if (plot instanceof Zoomable) {<a name="line.3040"></a>
<span class="sourceLineNo">3041</span>            Zoomable z = (Zoomable) plot;<a name="line.3041"></a>
<span class="sourceLineNo">3042</span>            isDomainZoomable = z.isDomainZoomable();<a name="line.3042"></a>
<span class="sourceLineNo">3043</span>            isRangeZoomable = z.isRangeZoomable();<a name="line.3043"></a>
<span class="sourceLineNo">3044</span>        }<a name="line.3044"></a>
<span class="sourceLineNo">3045</span><a name="line.3045"></a>
<span class="sourceLineNo">3046</span>        if (this.zoomInDomainMenuItem != null) {<a name="line.3046"></a>
<span class="sourceLineNo">3047</span>            this.zoomInDomainMenuItem.setEnabled(isDomainZoomable);<a name="line.3047"></a>
<span class="sourceLineNo">3048</span>        }<a name="line.3048"></a>
<span class="sourceLineNo">3049</span>        if (this.zoomOutDomainMenuItem != null) {<a name="line.3049"></a>
<span class="sourceLineNo">3050</span>            this.zoomOutDomainMenuItem.setEnabled(isDomainZoomable);<a name="line.3050"></a>
<span class="sourceLineNo">3051</span>        }<a name="line.3051"></a>
<span class="sourceLineNo">3052</span>        if (this.zoomResetDomainMenuItem != null) {<a name="line.3052"></a>
<span class="sourceLineNo">3053</span>            this.zoomResetDomainMenuItem.setEnabled(isDomainZoomable);<a name="line.3053"></a>
<span class="sourceLineNo">3054</span>        }<a name="line.3054"></a>
<span class="sourceLineNo">3055</span><a name="line.3055"></a>
<span class="sourceLineNo">3056</span>        if (this.zoomInRangeMenuItem != null) {<a name="line.3056"></a>
<span class="sourceLineNo">3057</span>            this.zoomInRangeMenuItem.setEnabled(isRangeZoomable);<a name="line.3057"></a>
<span class="sourceLineNo">3058</span>        }<a name="line.3058"></a>
<span class="sourceLineNo">3059</span>        if (this.zoomOutRangeMenuItem != null) {<a name="line.3059"></a>
<span class="sourceLineNo">3060</span>            this.zoomOutRangeMenuItem.setEnabled(isRangeZoomable);<a name="line.3060"></a>
<span class="sourceLineNo">3061</span>        }<a name="line.3061"></a>
<span class="sourceLineNo">3062</span><a name="line.3062"></a>
<span class="sourceLineNo">3063</span>        if (this.zoomResetRangeMenuItem != null) {<a name="line.3063"></a>
<span class="sourceLineNo">3064</span>            this.zoomResetRangeMenuItem.setEnabled(isRangeZoomable);<a name="line.3064"></a>
<span class="sourceLineNo">3065</span>        }<a name="line.3065"></a>
<span class="sourceLineNo">3066</span><a name="line.3066"></a>
<span class="sourceLineNo">3067</span>        if (this.zoomInBothMenuItem != null) {<a name="line.3067"></a>
<span class="sourceLineNo">3068</span>            this.zoomInBothMenuItem.setEnabled(isDomainZoomable<a name="line.3068"></a>
<span class="sourceLineNo">3069</span>                    &amp;&amp; isRangeZoomable);<a name="line.3069"></a>
<span class="sourceLineNo">3070</span>        }<a name="line.3070"></a>
<span class="sourceLineNo">3071</span>        if (this.zoomOutBothMenuItem != null) {<a name="line.3071"></a>
<span class="sourceLineNo">3072</span>            this.zoomOutBothMenuItem.setEnabled(isDomainZoomable<a name="line.3072"></a>
<span class="sourceLineNo">3073</span>                    &amp;&amp; isRangeZoomable);<a name="line.3073"></a>
<span class="sourceLineNo">3074</span>        }<a name="line.3074"></a>
<span class="sourceLineNo">3075</span>        if (this.zoomResetBothMenuItem != null) {<a name="line.3075"></a>
<span class="sourceLineNo">3076</span>            this.zoomResetBothMenuItem.setEnabled(isDomainZoomable<a name="line.3076"></a>
<span class="sourceLineNo">3077</span>                    &amp;&amp; isRangeZoomable);<a name="line.3077"></a>
<span class="sourceLineNo">3078</span>        }<a name="line.3078"></a>
<span class="sourceLineNo">3079</span><a name="line.3079"></a>
<span class="sourceLineNo">3080</span>        this.popup.show(this, x, y);<a name="line.3080"></a>
<span class="sourceLineNo">3081</span><a name="line.3081"></a>
<span class="sourceLineNo">3082</span>    }<a name="line.3082"></a>
<span class="sourceLineNo">3083</span><a name="line.3083"></a>
<span class="sourceLineNo">3084</span>    /**<a name="line.3084"></a>
<span class="sourceLineNo">3085</span>     * Updates the UI for a LookAndFeel change.<a name="line.3085"></a>
<span class="sourceLineNo">3086</span>     */<a name="line.3086"></a>
<span class="sourceLineNo">3087</span>    public void updateUI() {<a name="line.3087"></a>
<span class="sourceLineNo">3088</span>        // here we need to update the UI for the popup menu, if the panel<a name="line.3088"></a>
<span class="sourceLineNo">3089</span>        // has one...<a name="line.3089"></a>
<span class="sourceLineNo">3090</span>        if (this.popup != null) {<a name="line.3090"></a>
<span class="sourceLineNo">3091</span>            SwingUtilities.updateComponentTreeUI(this.popup);<a name="line.3091"></a>
<span class="sourceLineNo">3092</span>        }<a name="line.3092"></a>
<span class="sourceLineNo">3093</span>        super.updateUI();<a name="line.3093"></a>
<span class="sourceLineNo">3094</span>    }<a name="line.3094"></a>
<span class="sourceLineNo">3095</span><a name="line.3095"></a>
<span class="sourceLineNo">3096</span>    /**<a name="line.3096"></a>
<span class="sourceLineNo">3097</span>     * Provides serialization support.<a name="line.3097"></a>
<span class="sourceLineNo">3098</span>     *<a name="line.3098"></a>
<span class="sourceLineNo">3099</span>     * @param stream  the output stream.<a name="line.3099"></a>
<span class="sourceLineNo">3100</span>     *<a name="line.3100"></a>
<span class="sourceLineNo">3101</span>     * @throws IOException  if there is an I/O error.<a name="line.3101"></a>
<span class="sourceLineNo">3102</span>     */<a name="line.3102"></a>
<span class="sourceLineNo">3103</span>    private void writeObject(ObjectOutputStream stream) throws IOException {<a name="line.3103"></a>
<span class="sourceLineNo">3104</span>        stream.defaultWriteObject();<a name="line.3104"></a>
<span class="sourceLineNo">3105</span>        SerialUtilities.writePaint(this.zoomFillPaint, stream);<a name="line.3105"></a>
<span class="sourceLineNo">3106</span>        SerialUtilities.writePaint(this.zoomOutlinePaint, stream);<a name="line.3106"></a>
<span class="sourceLineNo">3107</span>    }<a name="line.3107"></a>
<span class="sourceLineNo">3108</span><a name="line.3108"></a>
<span class="sourceLineNo">3109</span>    /**<a name="line.3109"></a>
<span class="sourceLineNo">3110</span>     * Provides serialization support.<a name="line.3110"></a>
<span class="sourceLineNo">3111</span>     *<a name="line.3111"></a>
<span class="sourceLineNo">3112</span>     * @param stream  the input stream.<a name="line.3112"></a>
<span class="sourceLineNo">3113</span>     *<a name="line.3113"></a>
<span class="sourceLineNo">3114</span>     * @throws IOException  if there is an I/O error.<a name="line.3114"></a>
<span class="sourceLineNo">3115</span>     * @throws ClassNotFoundException  if there is a classpath problem.<a name="line.3115"></a>
<span class="sourceLineNo">3116</span>     */<a name="line.3116"></a>
<span class="sourceLineNo">3117</span>    private void readObject(ObjectInputStream stream)<a name="line.3117"></a>
<span class="sourceLineNo">3118</span>        throws IOException, ClassNotFoundException {<a name="line.3118"></a>
<span class="sourceLineNo">3119</span>        stream.defaultReadObject();<a name="line.3119"></a>
<span class="sourceLineNo">3120</span>        this.zoomFillPaint = SerialUtilities.readPaint(stream);<a name="line.3120"></a>
<span class="sourceLineNo">3121</span>        this.zoomOutlinePaint = SerialUtilities.readPaint(stream);<a name="line.3121"></a>
<span class="sourceLineNo">3122</span><a name="line.3122"></a>
<span class="sourceLineNo">3123</span>        // we create a new but empty chartMouseListeners list<a name="line.3123"></a>
<span class="sourceLineNo">3124</span>        this.chartMouseListeners = new EventListenerList();<a name="line.3124"></a>
<span class="sourceLineNo">3125</span><a name="line.3125"></a>
<span class="sourceLineNo">3126</span>        // register as a listener with sub-components...<a name="line.3126"></a>
<span class="sourceLineNo">3127</span>        if (this.chart != null) {<a name="line.3127"></a>
<span class="sourceLineNo">3128</span>            this.chart.addChangeListener(this);<a name="line.3128"></a>
<span class="sourceLineNo">3129</span>        }<a name="line.3129"></a>
<span class="sourceLineNo">3130</span><a name="line.3130"></a>
<span class="sourceLineNo">3131</span>    }<a name="line.3131"></a>
<span class="sourceLineNo">3132</span><a name="line.3132"></a>
<span class="sourceLineNo">3133</span>}<a name="line.3133"></a>




























































</pre>
</div>
</body>
</html>
